tournament homepage leaderboard

pull/2322/head
Thibault Duplessis 2016-10-17 18:07:10 +02:00
parent cf6f93fdb3
commit 65fe3f481d
4 changed files with 31 additions and 18 deletions

View File

@ -29,9 +29,9 @@ object Tournament extends LilaController {
else env.api.fetchVisibleTournaments zip
repo.scheduledDedup zip
finishedPaginator zip
Env.user.cached.topToints(true) map {
case (((visible, scheduled), finished), leaderboard) =>
Ok(html.tournament.home(scheduled, finished, leaderboard, env scheduleJsonView visible))
env.winners.all map {
case (((visible, scheduled), finished), winners) =>
Ok(html.tournament.home(scheduled, finished, winners, env scheduleJsonView visible))
} map NoCache
},
api = _ => env.api.fetchVisibleTournaments map { tours =>

View File

@ -1,4 +1,4 @@
@(scheduled: List[Tournament], finished: Paginator[Tournament], leaderboard: List[User], json: play.api.libs.json.JsObject)(implicit ctx: Context)
@(scheduled: List[Tournament], finished: Paginator[Tournament], winners: lila.tournament.AllWinners, json: play.api.libs.json.JsObject)(implicit ctx: Context)
@moreJs = {
@jsTag("vendor/jquery.infinitescroll.min.js")
@ -20,12 +20,17 @@ lichess.StrongSocket.defaults.events.reload = app.update;
<div class="tournament_links">
<a href="@routes.Tournament.help("arena".some)">@trans.tournamentFAQ()</a>
</div>
<h2 class="leaderboard_title">@trans.leaderboard()</h2>
<ol class="tournament_leaderboard">
@leaderboard.map { user =>
<li>@userLink(user, withOnline = false, text = Some(user.username + " [" + user.toints.localize + "]"))</li>
<h2 class="leaderboard_title">
<a href="@routes.Tournament.leaderboard">@trans.leaderboard()</a>
</h2>
<ul class="tournament_leaderboard">
@winners.top.take(10).map { w =>
<li>
@userIdLink(w.userId.some)
<a title="@w.tourName" href="@routes.Tournament.show(w.tourId)">@scheduledTournamentNameShortHtml(w.tourName)</a>
</li>
}
</ol>
</ul>
<h2 class="leaderboard_title">@trans.lichessTournaments()</h2>
<ol class="scheduled_tournaments">
@scheduled.map { tour =>

View File

@ -88,11 +88,6 @@ final class Cached(
f = UserRepo.byIdsSortRating(onlineUserIdMemo.keys, 50),
timeToLive = 10 seconds)
val topToints = mongoCache.single[List[User]](
prefix = "user:top:toints",
f = UserRepo allSortToints 10,
timeToLive = 5 minutes)
object ranking {
def getAll(userId: User.ID): Fu[Map[Perf.Key, Int]] =

View File

@ -725,12 +725,25 @@ div.faq_box {
margin-bottom: 6px;
border-bottom: 1px solid #ccc;
}
ol.tournament_leaderboard li {
padding: 5px 0;
list-style: decimal-leading-zero inside;
.tournament_leaderboard li {
width: 100%;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
line-height: 2.2em;
white-space: nowrap;
text-overflow: ellipsis;
}
.tournament_leaderboard a.user_link {
margin: 0 5px 0 -3px;
overflow: hidden;
text-overflow: ellipsis;
}
.tournament_leaderboard span {
opacity: 0.7;
}
.tournament_leaderboard li:hover a,
.leaderboard_title:hover a {
color: #3893E8;
}
ol.scheduled_tournaments li {
padding: 5px 0;