Skip to content

Commit

Permalink
exclude simul games from mod view - closes lichess-org/tavern#46
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Mar 6, 2021
1 parent 01c3c6c commit 77747cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/controllers/GameMod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ object GameMod {

val emptyFilter = Filter(none, none, none)

def toDbSelect(filter: Filter): Bdoc = filter.arena.?? { id =>
$doc(lila.game.Game.BSONFields.tournamentId -> id)
} ++ filter.swiss.?? { id =>
$doc(lila.game.Game.BSONFields.swissId -> id)
} ++ (filter.opponentIds match {
case Nil => $empty
case List(id) => $and(lila.game.Game.BSONFields.playerUids $eq id)
case ids => $and(lila.game.Game.BSONFields.playerUids $in ids)
})
def toDbSelect(filter: Filter): Bdoc =
lila.game.Query.notSimul ++ filter.arena.?? { id =>
$doc(lila.game.Game.BSONFields.tournamentId -> id)
} ++ filter.swiss.?? { id =>
$doc(lila.game.Game.BSONFields.swissId -> id)
} ++ (filter.opponentIds match {
case Nil => $empty
case List(id) => $and(lila.game.Game.BSONFields.playerUids $eq id)
case ids => $and(lila.game.Game.BSONFields.playerUids $in ids)
})

val filterForm =
Form(
Expand Down
2 changes: 2 additions & 0 deletions modules/game/src/main/Query.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ object Query {
case _ => $empty
}

val notSimul = F.simulId $exists false

val sortCreated: Bdoc = $sort desc F.createdAt
val sortChronological: Bdoc = $sort asc F.createdAt
val sortAntiChronological: Bdoc = $sort desc F.createdAt
Expand Down

0 comments on commit 77747cd

Please sign in to comment.