remove relay game ID PGN tag

pull/3627/head
Thibault Duplessis 2017-10-05 12:28:07 -05:00
parent 146e8d5a33
commit b4a4f8d271
2 changed files with 9 additions and 6 deletions

View File

@ -1,7 +1,7 @@
package lila.relay
import lila.study.{ Node }
import chess.format.pgn.Tags
import lila.study.{ Chapter, Node }
case class RelayGame(
tags: Tags,
@ -10,12 +10,17 @@ case class RelayGame(
blackName: RelayGame.PlayerName
) {
def id = s"$whiteName - $blackName, ${tags(_.Event) | "?"}"
lazy val id = RelayGame.makeId(whiteName.value, blackName.value, tags(_.Event))
def is(c: Chapter) = id == RelayGame.makeId(~c.tags(_.White), ~c.tags(_.Black), c.tags(_.Event))
override def toString = id
}
object RelayGame {
def makeId(white: String, black: String, event: Option[String]) =
s"$white - $black, ${event | "?"}"
case class PlayerName(value: String) extends AnyVal with StringValue
}

View File

@ -17,7 +17,7 @@ private final class RelaySync(
for {
chapters <- chapterRepo orderedByStudy study.id
movesPerGame <- lila.common.Future.traverseSequentially(games) { game =>
chapters.find(_.tags(idTag) has game.id) match {
chapters.find(game.is) match {
case Some(chapter) => updateChapter(study, chapter, game)
case None => createChapter(study, game) flatMap { chapter =>
chapters.find(_.isEmptyInitial).ifTrue(chapter.order == 2).?? { initial =>
@ -85,7 +85,7 @@ private final class RelaySync(
chess.Color.White
),
root = game.root,
tags = game.tags + Tag(idTag, game.id),
tags = game.tags,
order = order,
ownerId = study.ownerId,
practice = false,
@ -103,6 +103,4 @@ private final class RelaySync(
)
private val socketUid = Uid("")
private val idTag = "RelayId"
}