show shield defender on tournament side - for #4029
This commit is contained in:
parent
d5f395a6f3
commit
c8e4116f10
|
@ -90,7 +90,8 @@ object Tournament extends LilaController {
|
|||
json <- env.jsonView(tour, page, ctx.me, none, version.some, ctx.lang)
|
||||
_ <- chat ?? { c => Env.user.lightUserApi.preloadMany(c.chat.userIds) }
|
||||
streamers <- streamerCache get tour.id
|
||||
} yield Ok(html.tournament.show(tour, verdicts, json, chat, streamers))).mon(_.http.response.tournament.show.website)
|
||||
shieldOwner <- env.shieldApi currentOwner tour
|
||||
} yield Ok(html.tournament.show(tour, verdicts, json, chat, streamers, shieldOwner))).mon(_.http.response.tournament.show.website)
|
||||
}
|
||||
},
|
||||
api = _ => repo byId id flatMap {
|
||||
|
|
|
@ -22,7 +22,7 @@ moreCss = moreCss) {
|
|||
<ul>
|
||||
@awards.map { a =>
|
||||
<li>
|
||||
@userIdLink(a.userId.some)
|
||||
@userIdLink(a.owner.value.some)
|
||||
<a href="@routes.Tournament.show(a.tourId)">@showDate(a.date)</a>
|
||||
</li>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(tour: Tournament, verdicts: lila.tournament.Condition.All.WithVerdicts, data: play.api.libs.json.JsObject, chatOption: Option[lila.chat.UserChat.Mine], streamers: Set[User.ID])(implicit ctx: Context)
|
||||
@(tour: Tournament, verdicts: lila.tournament.Condition.All.WithVerdicts, data: play.api.libs.json.JsObject, chatOption: Option[lila.chat.UserChat.Mine], streamers: Set[User.ID], shieldOwner: Option[lila.tournament.TournamentShield.OwnerId])(implicit ctx: Context)
|
||||
|
||||
@underchat = {
|
||||
<div class="watchers hidden">
|
||||
|
@ -28,7 +28,7 @@ chat.ChatJsData.json(c.chat, name = trans.chatRoom.txt(), timeout = c.timeout, p
|
|||
|
||||
@tournament.layout(
|
||||
title = s"${tour.fullName} #${tour.id}",
|
||||
side = tournament.side(tour, verdicts, streamers).some,
|
||||
side = tournament.side(tour, verdicts, streamers, shieldOwner).some,
|
||||
chat = chat.dom().some,
|
||||
underchat = underchat.some,
|
||||
moreJs = moreJs,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(tour: Tournament, verdicts: lila.tournament.Condition.All.WithVerdicts, streamers: Set[User.ID])(implicit ctx: Context)
|
||||
@(tour: Tournament, verdicts: lila.tournament.Condition.All.WithVerdicts, streamers: Set[User.ID], shieldOwner: Option[lila.tournament.TournamentShield.OwnerId])(implicit ctx: Context)
|
||||
|
||||
<div class="side_box padded">
|
||||
<div class="game_infos" data-icon="@tour.perfType.map(_.iconChar)">
|
||||
|
@ -27,6 +27,9 @@
|
|||
@tour.spotlight.map { s =>
|
||||
<div class="game_infos spotlight">
|
||||
@lila.common.String.html.markdownLinks(s.description)
|
||||
@shieldOwner.map { owner =>
|
||||
<p class="defender" data-icon="5">Defender:@userIdLink(owner.value.some)</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if(verdicts.relevant) {
|
||||
|
|
|
@ -57,7 +57,7 @@ final class JsonView(
|
|||
}
|
||||
stats <- statsApi(tour)
|
||||
myGameId <- me.ifTrue(myInfo.isDefined) ?? { fetchCurrentGameId(tour, _) }
|
||||
shieldOwner <- shieldApi.currentOwner(tour) map { _ ?? lightUserApi.sync }
|
||||
shieldOwner <- shieldApi.currentOwner(tour) map { _ ?? { o => lightUserApi sync o.value } }
|
||||
} yield Json.obj(
|
||||
"id" -> tour.id,
|
||||
"createdBy" -> tour.createdBy,
|
||||
|
|
|
@ -16,14 +16,14 @@ final class TournamentShieldApi(
|
|||
import BSONHandlers._
|
||||
|
||||
def active(u: User): Fu[List[Award]] = cache.get map {
|
||||
_.value.values.flatMap(_.headOption.filter(_.userId == u.id)).toList
|
||||
_.value.values.flatMap(_.headOption.filter(_.owner.value == u.id)).toList
|
||||
}
|
||||
|
||||
def history: Fu[History] = cache.get
|
||||
|
||||
def currentOwner(tour: Tournament): Fu[Option[User.ID]] = tour.isShield ?? {
|
||||
def currentOwner(tour: Tournament): Fu[Option[OwnerId]] = tour.isShield ?? {
|
||||
Category.of(tour) ?? { cat =>
|
||||
history.map(_.current(cat).map(_.userId))
|
||||
history.map(_.current(cat).map(_.owner))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ final class TournamentShieldApi(
|
|||
winner <- tour.winnerId
|
||||
} yield Award(
|
||||
categ = categ,
|
||||
userId = winner,
|
||||
owner = OwnerId(winner),
|
||||
date = tour.finishesAt,
|
||||
tourId = tour.id
|
||||
)
|
||||
|
@ -56,9 +56,11 @@ final class TournamentShieldApi(
|
|||
|
||||
object TournamentShield {
|
||||
|
||||
case class OwnerId(value: String) extends AnyVal
|
||||
|
||||
case class Award(
|
||||
categ: Category,
|
||||
userId: User.ID,
|
||||
owner: OwnerId,
|
||||
date: DateTime,
|
||||
tourId: Tournament.ID
|
||||
)
|
||||
|
@ -69,7 +71,7 @@ object TournamentShield {
|
|||
categ -> ~(value get categ)
|
||||
}
|
||||
|
||||
def userIds: List[User.ID] = value.values.flatMap(_.map(_.userId)).toList
|
||||
def userIds: List[User.ID] = value.values.flatMap(_.map(_.owner.value)).toList
|
||||
|
||||
def current(cat: Category): Option[Award] = value get cat flatMap (_.headOption)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ object Dependencies {
|
|||
}
|
||||
|
||||
val scalaz = "org.scalaz" %% "scalaz-core" % "7.2.16"
|
||||
val scalalib = "com.github.ornicar" %% "scalalib" % "6.5"
|
||||
val scalalib = "com.github.ornicar" %% "scalalib" % "6.6"
|
||||
val typesafeConfig = "com.typesafe" % "config" % "1.3.1"
|
||||
val findbugs = "com.google.code.findbugs" % "jsr305" % "3.0.1"
|
||||
val hasher = "com.roundeights" %% "hasher" % "1.2.0"
|
||||
|
|
|
@ -482,6 +482,10 @@ div.side_box .game_infos.spotlight {
|
|||
div.side_box .game_infos.spotlight a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
div.side_box .game_infos .defender::before {
|
||||
font-size: 1.6em;
|
||||
vertical-align: -0.26em;
|
||||
}
|
||||
div.side_box .conditions::before {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue