refactor rating stats controller and hide more user ratings
parent
fd1594375e
commit
a3d1ead023
|
@ -140,7 +140,6 @@ final class LilaComponents(ctx: ApplicationLoader.Context) extends BuiltInCompon
|
||||||
lazy val search: Search = wire[Search]
|
lazy val search: Search = wire[Search]
|
||||||
lazy val setup: Setup = wire[Setup]
|
lazy val setup: Setup = wire[Setup]
|
||||||
lazy val simul: Simul = wire[Simul]
|
lazy val simul: Simul = wire[Simul]
|
||||||
lazy val stat: Stat = wire[Stat]
|
|
||||||
lazy val streamer: Streamer = wire[Streamer]
|
lazy val streamer: Streamer = wire[Streamer]
|
||||||
lazy val study: Study = wire[Study]
|
lazy val study: Study = wire[Study]
|
||||||
lazy val team: Team = wire[Team]
|
lazy val team: Team = wire[Team]
|
||||||
|
|
|
@ -211,7 +211,7 @@ Allow: /
|
||||||
case 103 => s"$faq#acpl"
|
case 103 => s"$faq#acpl"
|
||||||
case 258 => s"$faq#marks"
|
case 258 => s"$faq#marks"
|
||||||
case 13 => s"$faq#titles"
|
case 13 => s"$faq#titles"
|
||||||
case 87 => routes.Stat.ratingDistribution("blitz").url
|
case 87 => routes.User.ratingDistribution("blitz").url
|
||||||
case 110 => s"$faq#name"
|
case 110 => s"$faq#name"
|
||||||
case 29 => s"$faq#titles"
|
case 29 => s"$faq#titles"
|
||||||
case 4811 => s"$faq#lm"
|
case 4811 => s"$faq#lm"
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package controllers
|
|
||||||
|
|
||||||
import lila.app._
|
|
||||||
import views._
|
|
||||||
|
|
||||||
final class Stat(env: Env) extends LilaController(env) {
|
|
||||||
|
|
||||||
def ratingDistribution(perfKey: lila.rating.Perf.Key) =
|
|
||||||
Open { implicit ctx =>
|
|
||||||
lila.rating.PerfType(perfKey).filter(lila.rating.PerfType.leaderboardable.has) match {
|
|
||||||
case Some(perfType) =>
|
|
||||||
env.user.rankingApi.weeklyRatingDistribution(perfType) dmap { data =>
|
|
||||||
Ok(html.stat.ratingDistribution(perfType, data))
|
|
||||||
}
|
|
||||||
case _ => notFound
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -579,6 +579,17 @@ final class User(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ratingDistribution(perfKey: lila.rating.Perf.Key) =
|
||||||
|
Open { implicit ctx =>
|
||||||
|
lila.rating.PerfType(perfKey).filter(lila.rating.PerfType.leaderboardable.has) match {
|
||||||
|
case Some(perfType) =>
|
||||||
|
env.user.rankingApi.weeklyRatingDistribution(perfType) dmap { data =>
|
||||||
|
Ok(html.stat.ratingDistribution(perfType, data))
|
||||||
|
}
|
||||||
|
case _ => notFound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def myself =
|
def myself =
|
||||||
Auth { _ => me =>
|
Auth { _ => me =>
|
||||||
fuccess(Redirect(routes.User.show(me.username)))
|
fuccess(Redirect(routes.User.show(me.username)))
|
||||||
|
|
|
@ -41,33 +41,36 @@ object ratingDistribution {
|
||||||
a(
|
a(
|
||||||
dataIcon := pt.iconChar,
|
dataIcon := pt.iconChar,
|
||||||
cls := (perfType == pt).option("current"),
|
cls := (perfType == pt).option("current"),
|
||||||
href := routes.Stat.ratingDistribution(pt.key)
|
href := routes.User.ratingDistribution(pt.key)
|
||||||
)(pt.trans)
|
)(pt.trans)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
div(cls := "desc", dataIcon := perfType.iconChar)(
|
div(cls := "desc", dataIcon := perfType.iconChar)(
|
||||||
ctx.me.flatMap(_.perfs(perfType).glicko.establishedIntRating).map { rating =>
|
ctx.me.ifTrue(ctx.pref.showRatings).flatMap(_.perfs(perfType).glicko.establishedIntRating).map {
|
||||||
lila.user.Stat.percentile(data, rating) match {
|
rating =>
|
||||||
case (under, sum) =>
|
lila.user.Stat.percentile(data, rating) match {
|
||||||
div(
|
case (under, sum) =>
|
||||||
trans
|
div(
|
||||||
.nbPerfTypePlayersThisWeek(strong(sum.localize), perfType.trans),
|
trans
|
||||||
br,
|
.nbPerfTypePlayersThisWeek(strong(sum.localize), perfType.trans),
|
||||||
trans.yourPerfTypeRatingIsRating(perfType.trans, strong(rating)),
|
br,
|
||||||
br,
|
trans.yourPerfTypeRatingIsRating(perfType.trans, strong(rating)),
|
||||||
trans.youAreBetterThanPercentOfPerfTypePlayers(
|
br,
|
||||||
strong((under * 100.0 / sum).round, "%"),
|
trans.youAreBetterThanPercentOfPerfTypePlayers(
|
||||||
perfType.trans
|
strong((under * 100.0 / sum).round, "%"),
|
||||||
|
perfType.trans
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
} getOrElse div(
|
} getOrElse div(
|
||||||
trans.nbPerfTypePlayersThisWeek
|
trans.nbPerfTypePlayersThisWeek
|
||||||
.plural(data.sum, strong(data.sum.localize), perfType.trans),
|
.plural(data.sum, strong(data.sum.localize), perfType.trans),
|
||||||
br,
|
ctx.pref.showRatings option frag(
|
||||||
trans.youDoNotHaveAnEstablishedPerfTypeRating(perfType.trans)
|
br,
|
||||||
|
trans.youDoNotHaveAnEstablishedPerfTypeRating(perfType.trans)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
div(id := "rating_distribution_chart")(spinner)
|
div(id := "rating_distribution_chart")(spinner)
|
||||||
|
|
|
@ -14,7 +14,10 @@ object bits {
|
||||||
def communityMenu(active: String)(implicit ctx: Context) =
|
def communityMenu(active: String)(implicit ctx: Context) =
|
||||||
st.nav(cls := "page-menu__menu subnav")(
|
st.nav(cls := "page-menu__menu subnav")(
|
||||||
a(cls := active.active("leaderboard"), href := routes.User.list)(trans.leaderboard()),
|
a(cls := active.active("leaderboard"), href := routes.User.list)(trans.leaderboard()),
|
||||||
a(cls := active.active("ratings"), href := routes.Stat.ratingDistribution("blitz"))(
|
a(
|
||||||
|
cls := active.active("ratings"),
|
||||||
|
href := routes.User.ratingDistribution("blitz")
|
||||||
|
)(
|
||||||
trans.ratingStats()
|
trans.ratingStats()
|
||||||
),
|
),
|
||||||
a(cls := active.active("tournament"), href := routes.Tournament.leaderboard)(
|
a(cls := active.active("tournament"), href := routes.Tournament.leaderboard)(
|
||||||
|
|
|
@ -96,13 +96,13 @@ object perfStat {
|
||||||
span(cls := "details")(
|
span(cls := "details")(
|
||||||
if (ctx is u) {
|
if (ctx is u) {
|
||||||
trans.youAreBetterThanPercentOfPerfTypePlayers(
|
trans.youAreBetterThanPercentOfPerfTypePlayers(
|
||||||
a(href := routes.Stat.ratingDistribution(perfType.key))(strong(percentile, "%")),
|
a(href := routes.User.ratingDistribution(perfType.key))(strong(percentile, "%")),
|
||||||
a(href := routes.User.topNb(200, perfType.key))(perfType.trans)
|
a(href := routes.User.topNb(200, perfType.key))(perfType.trans)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
trans.userIsBetterThanPercentOfPerfTypePlayers(
|
trans.userIsBetterThanPercentOfPerfTypePlayers(
|
||||||
a(href := routes.User.show(u.username))(u.username),
|
a(href := routes.User.show(u.username))(u.username),
|
||||||
a(href := routes.Stat.ratingDistribution(perfType.key))(strong(percentile, "%")),
|
a(href := routes.User.ratingDistribution(perfType.key))(strong(percentile, "%")),
|
||||||
a(href := routes.User.topNb(200, perfType.key))(perfType.trans)
|
a(href := routes.User.topNb(200, perfType.key))(perfType.trans)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,7 +635,7 @@ POST /appeal/:username/snooze/:dur controllers.Appeal.snooze(username: Strin
|
||||||
POST /appeal/:username/send-to-zulip controllers.Appeal.sendToZulip(username: String)
|
POST /appeal/:username/send-to-zulip controllers.Appeal.sendToZulip(username: String)
|
||||||
|
|
||||||
# Stats
|
# Stats
|
||||||
GET /stat/rating/distribution/:perf controllers.Stat.ratingDistribution(perf: String)
|
GET /stat/rating/distribution/:perf controllers.User.ratingDistribution(perf: String)
|
||||||
|
|
||||||
# API
|
# API
|
||||||
GET /api controllers.Api.index
|
GET /api controllers.Api.index
|
||||||
|
|
Loading…
Reference in New Issue