reimport opening explorer master games - closes #1696
This commit is contained in:
parent
60b485dd75
commit
c1418ec842
|
@ -39,15 +39,19 @@ object Importer extends LilaController {
|
|||
)
|
||||
}
|
||||
|
||||
import lila.game.GameRepo
|
||||
import org.joda.time.DateTime
|
||||
private val masterGameEncodingFixedAt = new DateTime(2016, 3, 9, 0, 0)
|
||||
|
||||
def masterGame(id: String, orientation: String) = Open { implicit ctx =>
|
||||
def redirectAtFen(game: lila.game.Game) = Redirect {
|
||||
val url = routes.Round.watcher(game.id, orientation).url
|
||||
val fenParam = get("fen").??(f => s"?fen=$f")
|
||||
s"$url$fenParam"
|
||||
}
|
||||
lila.game.GameRepo game id flatMap {
|
||||
case Some(game) => fuccess(redirectAtFen(game))
|
||||
case _ => Env.explorer.fetchPgn(id) flatMap {
|
||||
GameRepo game id flatMap {
|
||||
case Some(game) if game.createdAt.isAfter(masterGameEncodingFixedAt) => fuccess(redirectAtFen(game))
|
||||
case _ => (GameRepo remove id) >> Env.explorer.fetchPgn(id) flatMap {
|
||||
case None => fuccess(NotFound)
|
||||
case Some(pgn) => env.importer(
|
||||
lila.importer.ImportData(pgn, none),
|
||||
|
|
Loading…
Reference in a new issue