diff --git a/README.md b/README.md index 2258bd470b..99358caa89 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ drop me an email at thibault.duplessis@gmail.com, and we'll discuss it. { "username": "thibault", "url": "http://lichess.org/@/thibault", // profile url - "rating": 1503, // global Glicko2 rating + "rating": 1503, // standard Glicko2 rating "progress": 36, // rating change over the last ten games "online": true, // is the player currently using lichess? "playing": "http://lichess.org/abcdefgh", // game being played, if any @@ -93,7 +93,7 @@ name | type | default | description { "username": "thibault", "url": "http://lichess.org/@/thibault", // profile url - "rating": 1503, // global Glicko2 rating + "rating": 1503, // standard Glicko2 rating "progress": 36, // rating change over the last ten games "online": true, // is the player currently using lichess? "engine": false // true if the user is known to use a chess engine diff --git a/app/controllers/User.scala b/app/controllers/User.scala index d327d8cb9b..7b2a242990 100644 --- a/app/controllers/User.scala +++ b/app/controllers/User.scala @@ -95,7 +95,7 @@ object User extends LilaController { Reasonable(page) { val nb = 10 for { - progressDay ← fuccess(Nil) + pool10 ← env.cached topPool1_0 nb tourneyWinners ← Env.tournament.winners scheduled nb toint <- env.cached topToints nb rating ← env.cached topRating nb @@ -115,7 +115,7 @@ object User extends LilaController { UserRepo.byOrderedIds(pairs.map(_._1)) map (_ zip pairs.map(_._2)) } } yield html.user.list( - progressDay = progressDay, + pool10 = pool10, tourneyWinners = tourneyWinners, toint = toint, rating = rating, diff --git a/app/views/user/list.scala.html b/app/views/user/list.scala.html index dc904133ed..25fa491c8f 100644 --- a/app/views/user/list.scala.html +++ b/app/views/user/list.scala.html @@ -1,4 +1,4 @@ -@(progressDay: List[User], tourneyWinners: List[lila.tournament.Winner], toint: List[User], rating: List[User], ratingDay: List[User], ratingWeek: List[User], online: List[User], bullet: List[User], blitz: List[User], classical: List[User], nb: List[(User, Int)], nbDay: List[(User, Int)], nbWeek: List[(User, Int)])(implicit ctx: Context) +@(pool10: List[User], tourneyWinners: List[lila.tournament.Winner], toint: List[User], rating: List[User], ratingDay: List[User], ratingWeek: List[User], online: List[User], bullet: List[User], blitz: List[User], classical: List[User], nb: List[(User, Int)], nbDay: List[(User, Int)], nbWeek: List[(User, Int)])(implicit ctx: Context) @side = {
@@ -31,7 +31,7 @@
- @user.topLeader(progressDay, trans.progressToday(), icon = "Q".some) + @user.topLeader(pool10, "1+0 Pool leaderboard", icon = "8".some) @user.topLeader(ratingDay, trans.todaysLeaders(), icon = "C".some) @user.topActive(nbDay, trans.activeToday(), true, icon = "T".some)
diff --git a/doc/mobile-api.md b/doc/mobile-api.md index a69407b80c..435512613d 100644 --- a/doc/mobile-api.md +++ b/doc/mobile-api.md @@ -186,7 +186,7 @@ Set-Cookie: lila2="3b5cc8c80f0af258a31dc4fd1b5381cabe7388c7-sessionId=80q7V5stkK "id": "thibault", "username": "thibault" "title": null, - "rating": 1438, // shortcut to global perf rating + "rating": 1438, // shortcut to standard perf rating "progress": -55, // rating progress over last 10 games "count": { // number of games played "ai": 256, diff --git a/modules/user/src/main/Cached.scala b/modules/user/src/main/Cached.scala index c7f584f5d8..74a8b5c482 100644 --- a/modules/user/src/main/Cached.scala +++ b/modules/user/src/main/Cached.scala @@ -31,6 +31,8 @@ final class Cached( val topBullet = AsyncCache(UserRepo.topBullet, timeToLive = 31 minutes) val topBlitz = AsyncCache(UserRepo.topBlitz, timeToLive = 32 minutes) val topClassical = AsyncCache(UserRepo.topClassical, timeToLive = 33 minutes) + val topChess960 = AsyncCache(UserRepo.topChess960, timeToLive = 36 minutes) + val topPool1_0 = AsyncCache(UserRepo.topPool1_0, timeToLive = 31 minutes) val topNbGame = AsyncCache(UserRepo.topNbGame, timeToLive = 34 minutes) val topPool = AsyncCache( diff --git a/modules/user/src/main/Ranking.scala b/modules/user/src/main/Ranking.scala index dd26e992fe..2aa5b2442c 100644 --- a/modules/user/src/main/Ranking.scala +++ b/modules/user/src/main/Ranking.scala @@ -20,7 +20,7 @@ private[user] final class Ranking(ttl: Duration) { private def compute: Fu[Map[String, Int]] = $primitive( UserRepo.stableGoodLadSelect ++ - UserRepo.perfSince("global", maxInactivityDate) ++ + UserRepo.perfSince("standard", maxInactivityDate) ++ Json.obj("rating" -> $gt(Glicko.default.intRating)), "_id", _ sort UserRepo.sortRatingDesc diff --git a/modules/user/src/main/UserRepo.scala b/modules/user/src/main/UserRepo.scala index eb26ef558b..ad1dda7784 100644 --- a/modules/user/src/main/UserRepo.scala +++ b/modules/user/src/main/UserRepo.scala @@ -31,15 +31,19 @@ trait UserRepo { def topRating(nb: Int): Fu[List[User]] = topRatingSince(maxInactivityDate, nb) - def topRatingSince(since: DateTime, nb: Int): Fu[List[User]] = - $find($query(stableGoodLadSelect ++ perfSince("global", since)) sort sortRatingDesc, nb) + def topRatingSince(since: DateTime, nb: Int, sincePerf: String = "standard"): Fu[List[User]] = + $find($query(stableGoodLadSelect ++ perfSince(sincePerf, since)) sort sortRatingDesc, nb) def topBullet = topPerf("bullet") _ def topBlitz = topPerf("blitz") _ def topClassical = topPerf("classical") _ + def topChess960 = topPerf("chess960") _ + + def topPool1_0 = topPerf("pools.1-0") _ + def topPerf(perf: String)(nb: Int): Fu[List[User]] = - $find($query(stableGoodLadSelect) sort ($sort desc s"perfs.$perf.gl.r"), nb) + $find($query(stableGoodLadSelect ++ activeSelect(perf)) sort ($sort desc s"perfs.$perf.gl.r"), nb) def topPool(poolId: String, nb: Int): Fu[List[User]] = $find($query( @@ -140,8 +144,8 @@ trait UserRepo { val enabledSelect = Json.obj(F.enabled -> true) def engineSelect(v: Boolean) = Json.obj(F.engine -> v.fold(JsBoolean(true), $ne(true))) - val stableSelect = Json.obj("perfs.global.nb" -> $gte(50)) - val activeSelect = perfSince("global", DateTime.now minusMonths 2) + val stableSelect = Json.obj("perfs.standard.nb" -> $gte(50)) + def activeSelect(sincePerf: String = "standard") = perfSince(sincePerf, DateTime.now minusMonths 2) val goodLadSelect = enabledSelect ++ engineSelect(false) val stableGoodLadSelect = stableSelect ++ goodLadSelect def minRatingSelect(rating: Int) = Json.obj(F.rating -> $gt(rating))