generic tour ranking fetch
This commit is contained in:
parent
195bf62bd4
commit
c99e23bc13
|
@ -19,13 +19,17 @@ private[tournament] final class Cached(
|
|||
TournamentRepo.promotable,
|
||||
timeToLive = createdTtl)
|
||||
|
||||
def ranking(tour: Tournament): Fu[Ranking] =
|
||||
if (tour.isFinished) finishedRanking(tour.id)
|
||||
else ongoingRanking(tour.id)
|
||||
|
||||
// only applies to ongoing tournaments
|
||||
val ongoingRanking = AsyncCache[String, Ranking](
|
||||
private val ongoingRanking = AsyncCache[String, Ranking](
|
||||
PlayerRepo.computeRanking,
|
||||
timeToLive = 3.seconds)
|
||||
|
||||
// only applies to finished tournaments
|
||||
val finishedRanking = AsyncCache[String, Ranking](
|
||||
private val finishedRanking = AsyncCache[String, Ranking](
|
||||
PlayerRepo.computeRanking,
|
||||
timeToLive = rankingTtl)
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ final class JsonView(
|
|||
firstPageCache.remove(id) >> cachableData.remove(id)
|
||||
|
||||
def playerInfo(info: PlayerInfoExt): Fu[JsObject] = for {
|
||||
ranking <- info.tour.isFinished.fold(cached.finishedRanking, cached.ongoingRanking)(info.tour.id)
|
||||
ranking <- cached ranking info.tour
|
||||
pairings <- PairingRepo.finishedByPlayerChronological(info.tour.id, info.user.id)
|
||||
sheet = info.tour.system.scoringSystem.sheet(info.tour, info.user.id, pairings)
|
||||
tpr <- performance(info.tour, info.player, pairings)
|
||||
|
|
|
@ -62,7 +62,7 @@ private[tournament] final class TournamentApi(
|
|||
|
||||
def makePairings(oldTour: Tournament, users: WaitingUsers, startAt: Long) {
|
||||
Sequencing(oldTour.id)(TournamentRepo.startedById) { tour =>
|
||||
cached.ongoingRanking(tour.id) flatMap { ranking =>
|
||||
cached ranking tour flatMap { ranking =>
|
||||
tour.system.pairingSystem.createPairings(tour, users, ranking) flatMap {
|
||||
case Nil => funit
|
||||
case pairings if nowMillis - startAt > 1000 =>
|
||||
|
|
Loading…
Reference in a new issue