also remove pgn docs when removing games
This commit is contained in:
parent
bf95c4dd4a
commit
de339c4b85
|
@ -159,6 +159,7 @@ final class CoreEnv private (application: Application, val settings: Settings) {
|
|||
|
||||
lazy val titivate = new lila.core.Titivate(
|
||||
gameRepo = game.gameRepo,
|
||||
pgnRepo = game.pgnRepo,
|
||||
finisher = round.finisher,
|
||||
meddler = round.meddler,
|
||||
bookmarkApi = bookmark.api)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila
|
||||
package core
|
||||
|
||||
import game.GameRepo
|
||||
import game.{ GameRepo, PgnRepo }
|
||||
import round.{ Finisher, Meddler }
|
||||
import bookmark.BookmarkApi
|
||||
|
||||
|
@ -12,6 +12,7 @@ import scalaz.effects._
|
|||
|
||||
final class Titivate(
|
||||
gameRepo: GameRepo,
|
||||
pgnRepo: PgnRepo,
|
||||
finisher: Finisher,
|
||||
meddler: Meddler,
|
||||
bookmarkApi: BookmarkApi) {
|
||||
|
@ -33,6 +34,7 @@ final class Titivate(
|
|||
_ ← putStrLn("[titivate] Remove %d unplayed games" format ids.size)
|
||||
_ ← gameRepo removeIds ids
|
||||
_ ← bookmarkApi removeByGameIds ids
|
||||
_ ← pgnRepo removeIds ids
|
||||
} yield ()
|
||||
|
||||
val cleanupNext: IO[Unit] = {
|
||||
|
|
|
@ -145,11 +145,12 @@ final class GameRepo(collection: MongoCollection)
|
|||
)
|
||||
}
|
||||
|
||||
// bookmarks should also be removed
|
||||
// bookmarks and pgns should also be removed
|
||||
def remove(id: String): IO[Unit] = io {
|
||||
remove(idSelector(id))
|
||||
}
|
||||
|
||||
// bookmarks and pgns should also be removed
|
||||
def removeIds(ids: List[String]): IO[Unit] = io {
|
||||
remove("_id" $in ids)
|
||||
}
|
||||
|
|
|
@ -25,5 +25,9 @@ final class PgnRepo(collection: MongoCollection) {
|
|||
def unsafeGet(id: String): String =
|
||||
collection.findOne(idSelector(id)).flatMap(_.getAs[String]("p")) | ""
|
||||
|
||||
def removeIds(ids: List[String]): IO[Unit] = io {
|
||||
collection.remove("_id" $in ids)
|
||||
}
|
||||
|
||||
private def idSelector(id: String) = DBObject("_id" -> id)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue