filter game export by colour
This commit is contained in:
parent
b1fdfeda0b
commit
f7b3c562d7
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue