cheaper user perf stats pages (only fetch ranks)

pull/1352/head
Thibault Duplessis 2015-12-26 09:44:56 +07:00
parent 899d004695
commit 198984fba1
6 changed files with 12 additions and 9 deletions

View File

@ -227,9 +227,9 @@ object User extends LilaController {
if ((u.disabled || (u.lame && !ctx.is(u))) && !isGranted(_.UserSpy)) notFound
else lila.rating.PerfType(perfKey).fold(notFound) { perfType =>
Env.perfStat.get(u, perfType).flatMap { perfStat =>
Env.current.userInfo(u, ctx).map { info =>
Env.user.cached.ranking.getAll(u.id).map { ranks =>
val data = Env.perfStat.jsonView(perfStat)
Ok(html.user.perfStat(u, info, perfStat.perfType, data))
Ok(html.user.perfStat(u, ranks, perfStat.perfType, data))
}
}
}

View File

@ -14,7 +14,7 @@ import lila.user.{ User, Trophy, Trophies, TrophyApi }
case class UserInfo(
user: User,
ranks: Map[lila.rating.Perf.Key, Int],
ranks: lila.rating.UserRankMap,
nbUsers: Int,
nbPlaying: Int,
hasSimul: Boolean,

View File

@ -1,4 +1,4 @@
@(u: User, info: lila.app.mashup.UserInfo, perfType: lila.rating.PerfType, data: play.api.libs.json.JsObject)(implicit ctx: Context)
@(u: User, rankMap: lila.rating.UserRankMap, perfType: lila.rating.PerfType, data: play.api.libs.json.JsObject)(implicit ctx: Context)
@moreJs = {
@jsAt(s"compiled/lichess.perfStat${isProd??(".min")}.js")
@ -15,7 +15,7 @@ i18n: {}
@user.layout(
title = s"${u.username} ${perfType.name} stats",
side = side(u, info, perfType.some).some,
side = side(u, rankMap, perfType.some).some,
robots = false,
evenMoreJs = moreJs) {
<div class="content_box no_padding user_show">

View File

@ -24,7 +24,7 @@ if (lichess.once('user-tournaments-tour')) setTimeout(lichess.startTournamentSta
@user.layout(
title = s"${u.username} : ${userGameFilterTitleNoTag(info, filters.current)}${if(games.currentPage == 1) "" else " - page " + games.currentPage}",
side = side(u, info, none).some,
side = side(u, info.ranks, none).some,
robots = false,
evenMoreJs = evenMoreJs,
openGraph = lila.app.ui.OpenGraph(

View File

@ -1,4 +1,4 @@
@(u: User, info: lila.app.mashup.UserInfo, active: Option[lila.rating.PerfType])(implicit ctx: Context)
@(u: User, rankMap: lila.rating.UserRankMap, active: Option[lila.rating.PerfType])(implicit ctx: Context)
@import lila.rating.PerfType
@ -16,7 +16,7 @@
@showProgress(perf.progress)
</span>
<span class="rank" title="Rank is updated every 15 minutes">
@info.ranks.get(perfType.key).map { rank =>
@rankMap.get(perfType.key).map { rank =>
Rank: @rank.localize@nth(rank)
}
</span>

View File

@ -1,3 +1,6 @@
package lila
package object rating extends PackageObject
package object rating extends PackageObject {
type UserRankMap = Map[lila.rating.Perf.Key, Int]
}