only save leaderboardable perf types in rankings

pull/9923/head
Thibault Duplessis 2021-10-03 10:37:43 +02:00
parent 6abfc8dccd
commit 3cf76bad3f
2 changed files with 3 additions and 2 deletions

View File

@ -234,6 +234,7 @@ object PerfType {
Horde,
RacingKings
)
val isLeaderboardable = leaderboardable.toSet
val variants: List[PerfType] =
List(Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val standard: List[PerfType] = List(Bullet, Blitz, Rapid, Classical, Correspondence)

View File

@ -27,7 +27,7 @@ final class RankingApi(
}
def save(user: User, perfType: PerfType, perf: Perf): Funit =
(user.rankable && perf.nb >= 2) ?? coll {
(user.rankable && perf.nb >= 2 && PerfType.isLeaderboardable(perfType)) ?? coll {
_.update
.one(
$id(makeId(user.id, perfType)),
@ -52,7 +52,7 @@ final class RankingApi(
s"$userId:${perfType.id}"
private[user] def topPerf(perfId: Perf.ID, nb: Int): Fu[List[User.LightPerf]] =
PerfType.id2key(perfId).filter(PerfType.leaderboardable.contains) ?? { perfKey =>
PerfType.id2key(perfId).filter(k => PerfType(k).exists(PerfType.isLeaderboardable)) ?? { perfKey =>
coll {
_.find($doc("perf" -> perfId, "stable" -> true))
.sort($doc("rating" -> -1))