add debugging to the tournament point counter

This commit is contained in:
Thibault Duplessis 2014-04-28 01:35:38 +02:00
parent ef5d26c46a
commit 58443d6591
2 changed files with 5 additions and 3 deletions

View file

@ -94,7 +94,7 @@ private[tournament] final class TournamentApi(
(pairingsToAbort foreach { pairing =>
roundMap ! Tell(pairing.gameId, AbortForce)
}) >>
finished.players.filter(_.score > 0).map(p => UserRepo.incToints(p.id)(p.score)).sequenceFu inject finished
finished.players.filter(_.score > 0).map(p => UserRepo.incToints(p.id, p.score)).sequenceFu inject finished
}, fuccess(started))
def join(tour: Enterable, me: User, password: Option[String]): Funit =
@ -138,8 +138,10 @@ private[tournament] final class TournamentApi(
def recountAll = UserRepo.removeAllToints >> funit
$enumerate.over($query[Finished](TournamentRepo.finishedQuery)) { (tour: Finished) =>
val tour2 = tour.refreshPlayers
val players = tour.players.filter(_.score > 0)
println(s"tour ${tour2.id}: ${players.size}")
$update(tour2) zip
tour.players.filter(_.score > 0).map(p => UserRepo.incToints(p.id)(p.score)).sequenceFu void
players.map(p => UserRepo.incToints(p.id, p.score)).sequenceFu void
}
private def tripleQuickLossWithdraw(tour: Started, loser: Option[String]): Funit =

View file

@ -148,7 +148,7 @@ trait UserRepo {
$update($select(id), $incBson(incs: _*))
}
def incToints(id: ID)(nb: Int) = $update($select(id), $incBson("toints" -> nb))
def incToints(id: ID, nb: Int) = $update($select(id), $incBson("toints" -> nb))
def removeAllToints = $update($select.all, $unset("toints"), multi = true)
def averageRating: Fu[Float] = $primitive($select.all, "rating")(_.asOpt[Float]) map { ratings =>