add daily crazyhouse to tournament winners leaderboard
This commit is contained in:
parent
a9c73f1234
commit
d0a1c43a13
|
@ -124,7 +124,7 @@ object PlayerRepo {
|
|||
b += (u.get.asInstanceOf[BSONString].value -> r)
|
||||
r = r + 1
|
||||
}
|
||||
b.result()
|
||||
b.result
|
||||
case _ => Map.empty
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package lila.tournament
|
|||
|
||||
import org.joda.time.DateTime
|
||||
import reactivemongo.bson.{ BSONDocument, BSONArray, BSONInteger }
|
||||
import chess.variant.Variant
|
||||
|
||||
import BSONHandlers._
|
||||
import lila.common.paginator.Paginator
|
||||
|
@ -25,7 +26,7 @@ object TournamentRepo {
|
|||
private val unfinishedSelect = BSONDocument("status" -> BSONDocument("$ne" -> Status.Finished.id))
|
||||
private[tournament] val scheduledSelect = BSONDocument("schedule" -> BSONDocument("$exists" -> true))
|
||||
private def sinceSelect(date: DateTime) = BSONDocument("startsAt" -> BSONDocument("$gt" -> date))
|
||||
private def variantSelect(variant: chess.variant.Variant) =
|
||||
private def variantSelect(variant: Variant) =
|
||||
if (variant.standard) BSONDocument("variant" -> BSONDocument("$exists" -> false))
|
||||
else BSONDocument("variant" -> variant.id)
|
||||
|
||||
|
@ -177,13 +178,18 @@ object TournamentRepo {
|
|||
}._1.reverse
|
||||
}
|
||||
|
||||
def lastFinishedScheduledByFreqStandard(freq: Schedule.Freq, since: DateTime): Fu[List[Tournament]] = coll.find(
|
||||
def lastFinishedScheduledByFreq(freq: Schedule.Freq, since: DateTime): Fu[List[Tournament]] = coll.find(
|
||||
finishedSelect ++ sinceSelect(since) ++ variantSelect(chess.variant.Standard) ++ BSONDocument(
|
||||
"schedule.freq" -> freq.name,
|
||||
"schedule.speed" -> BSONDocument("$in" -> Schedule.Speed.mostPopular.map(_.name))
|
||||
)
|
||||
).sort(BSONDocument("startsAt" -> -1)).toList[Tournament](Schedule.Speed.mostPopular.size.some)
|
||||
|
||||
def lastFinishedDaily(variant: Variant): Fu[Option[Tournament]] = coll.find(
|
||||
finishedSelect ++ sinceSelect(DateTime.now minusDays 1) ++ variantSelect(variant) ++
|
||||
BSONDocument("schedule.freq" -> Schedule.Freq.Daily.name)
|
||||
).sort(BSONDocument("startsAt" -> -1)).one[Tournament]
|
||||
|
||||
def update(tour: Tournament) = coll.update(BSONDocument("_id" -> tour.id), tour)
|
||||
|
||||
def insert(tour: Tournament) = coll.insert(tour)
|
||||
|
|
|
@ -21,9 +21,11 @@ final class Winners(
|
|||
import Schedule.Freq
|
||||
private def fetchScheduled(nb: Int): Fu[List[Winner]] = {
|
||||
val since = DateTime.now minusMonths 1
|
||||
List(Freq.Marathon, Freq.Monthly, Freq.Weekly, Freq.Daily).map { freq =>
|
||||
TournamentRepo.lastFinishedScheduledByFreqStandard(freq, since) flatMap toursToWinners
|
||||
}.sequenceFu.map(_.flatten)
|
||||
List(Freq.Monthly, Freq.Weekly, Freq.Daily).map { freq =>
|
||||
TournamentRepo.lastFinishedScheduledByFreq(freq, since)
|
||||
}.sequenceFu.map(_.flatten) flatMap { stds =>
|
||||
TournamentRepo.lastFinishedDaily(chess.variant.Crazyhouse) map (stds ::: _.toList)
|
||||
} flatMap toursToWinners
|
||||
}
|
||||
|
||||
private def toursToWinners(tours: List[Tournament]): Fu[List[Winner]] =
|
||||
|
|
Loading…
Reference in a new issue