also export ongoing games in /api/games/user

pull/9946/head
Thibault Duplessis 2021-10-07 10:50:41 +02:00
parent 2d0e6df79a
commit 1001dd6800
2 changed files with 7 additions and 3 deletions

View File

@ -96,7 +96,8 @@ final class Game(
case Some(_) if oauth => 30 // bonus for oauth logged in only (not for CSRF)
case _ => 20
}),
playerFile = get("players", req)
playerFile = get("players", req),
ongoing = getBool("ongoing", req)
)
val date = DateTimeFormat forPattern "yyyy-MM-dd" print new DateTime
apiC

View File

@ -113,7 +113,9 @@ final class GameApiV2(
gameRepo
.sortedCursor(
config.vs.fold(Query.user(config.user.id)) { Query.opponents(config.user, _) } ++
Query.createdBetween(config.since, config.until) ++ Query.finished,
Query.createdBetween(config.since, config.until) ++ {
!config.ongoing ?? Query.finished
},
config.sort.bson,
batchSize = config.perSecond.value
)
@ -364,7 +366,8 @@ object GameApiV2 {
flags: WithFlags,
sort: GameSort,
perSecond: MaxPerSecond,
playerFile: Option[String]
playerFile: Option[String],
ongoing: Boolean = false
) extends Config {
def postFilter(g: Game) =
rated.fold(true)(g.rated ==) && {