Revert "implement user version and rapid rating skip"

This reverts commit 2ffa225410.
This commit is contained in:
Thibault Duplessis 2017-12-02 07:09:00 -05:00
parent 6411d6c0be
commit e814c1cfce
2 changed files with 50 additions and 68 deletions

View file

@ -5,7 +5,7 @@ import org.goochjs.glicko2._
import lila.game.{ GameRepo, Game, PerfPicker, RatingDiffs }
import lila.history.HistoryApi
import lila.rating.{ Glicko, Perf, PerfType }
import lila.rating.{ Glicko, Perf }
import lila.user.{ UserRepo, User, Perfs, RankingApi }
final class PerfsUpdater(
@ -17,21 +17,10 @@ final class PerfsUpdater(
private val TAU = 0.75d
private val system = new RatingCalculator(VOLATILITY, TAU)
// during rapid migration
private def skipRapid(game: Game, white: User, black: User): Fu[Boolean] =
if (!game.perfType.has(PerfType.Rapid)) fuccess(false)
else if (List(white, black).forall(_.perfs.rapid.nb > 0)) fuccess(false)
else !UserRepo.haveVersion(List(white, black), 2)
// returns rating diffs
def save(game: Game, white: User, black: User): Fu[Option[RatingDiffs]] =
PerfPicker.main(game) ?? { mainPerf =>
(game.rated && game.finished && game.accountable && !white.lame && !black.lame) ?? {
skipRapid(game, white, black) flatMap {
case true =>
logger.info(s"Skip rapid perf update for ${game.id} - ${white.id} vs ${black.id}")
fuccess(none)
case false =>
val ratingsW = mkRatings(white.perfs)
val ratingsB = mkRatings(black.perfs)
val result = resultOf(game)
@ -84,7 +73,6 @@ final class PerfsUpdater(
rankingApi.save(black.id, game.perfType, perfsB) inject ratingDiffs.some
}
}
}
private final case class Ratings(
chess960: Rating,

View file

@ -92,12 +92,6 @@ object UserRepo {
_.flatMap { _.getAs[User.ID]("_id") }
}
def haveVersion(users: List[User], version: Int): Fu[Boolean] =
coll.countSel($doc(
F.id $in users.map(_.id),
"v" $gte version
)) map (users.size ==)
private[user] def allSortToints(nb: Int) =
coll.find($empty).sort($sort desc F.toints).cursor[User]().gather[List](nb)