broadcast: never replace source games coming from lichess

only append
swiss
Thibault Duplessis 2020-05-05 17:19:58 -06:00
parent 47ce4ea0b0
commit ab9c17b927
2 changed files with 9 additions and 1 deletions

View File

@ -21,9 +21,17 @@ case class RelayGame(
def finished = end.isDefined
def isEmpty = tags.value.isEmpty && root.children.nodes.isEmpty
lazy val looksLikeLichess = tags(_.Site) exists { site =>
RelayGame.lichessDomains exists { domain =>
site startsWith s"https://$domain/"
}
}
}
private object RelayGame {
val lichessDomains = List("lichess.org", "lichess.dev")
val staticTags = List("white", "black", "round", "event", "site")
}

View File

@ -47,7 +47,7 @@ final private class RelaySync(
chapters: List[Chapter],
nbGames: Int
): Option[Chapter] =
if (nbGames == 1) chapters find game.staticTagsMatch
if (nbGames == 1 || game.looksLikeLichess) chapters find game.staticTagsMatch
else chapters.find(_.relay.exists(_.index == game.index))
private def updateChapter(study: Study, chapter: Chapter, game: RelayGame): Fu[NbMoves] =