filter game export by colour

This commit is contained in:
Thibault Duplessis 2018-04-23 14:54:12 +02:00
parent b1fdfeda0b
commit f7b3c562d7
2 changed files with 4 additions and 0 deletions

View file

@ -45,6 +45,7 @@ object Game extends LilaController {
max = getInt("max", req) map (_ atLeast 1),
rated = getBoolOpt("rated", req),
perfType = ~get("perfType", req) split "," flatMap { lila.rating.PerfType(_) } toSet,
color = get("color", req) flatMap chess.Color.apply,
flags = lila.game.PgnDump.WithFlags(
moves = getBoolOpt("moves", req) | true,
tags = getBoolOpt("tags", req) | true,

View file

@ -64,12 +64,15 @@ object PgnDump {
max: Option[Int] = None,
rated: Option[Boolean] = None,
perfType: Set[lila.rating.PerfType],
color: Option[chess.Color],
flags: WithFlags,
perSecond: MaxPerSecond
) {
def postFilter(g: Game) =
rated.fold(true)(g.rated ==) && {
perfType.isEmpty || g.perfType.exists(perfType.contains)
} && color.fold(true) { c =>
g.player(c).userId has user.id
}
}
}