redefine abandoned games

pull/83/head
Thibault Duplessis 2013-09-26 11:05:30 +02:00
parent 2e447a52b5
commit f8bf12ddc4
2 changed files with 9 additions and 5 deletions

View File

@ -313,9 +313,7 @@ case class Game(
def olderThan(seconds: Int) = updatedAt.??(_ < DateTime.now - seconds.seconds)
def abandoned = updatedAt ?? { u
(status <= Status.Started) && (u <= Game.abandonedDate)
}
def abandoned = (status <= Status.Started) && (updatedAt | createdAt) < Game.abandonedDate
def hasBookmarks = bookmarks > 0
@ -384,7 +382,7 @@ object Game {
val updatedAt = "ua"
}
def abandonedDate = DateTime.now - 10.days
def abandonedDate = DateTime.now - 7.days
def takeGameId(fullId: String) = fullId take gameIdSize
def takePlayerId(fullId: String) = fullId drop gameIdSize

View File

@ -66,7 +66,13 @@ object Query {
def finishByClock = playable ++ clock(true) ++ Json.obj(
createdAt -> $gt($date(DateTime.now - 3.hour)))
def abandoned = notFinished ++ Json.obj(updatedAt -> $lt($date(Game.abandonedDate)))
def abandoned = {
val date = $date(Game.abandonedDate)
notFinished ++ $or(Seq(
Json.obj(updatedAt -> $lt(date)),
Json.obj(updatedAt -> $exists(false), createdAt -> $lt(date))
))
}
val sortCreated = $sort desc createdAt