reset chapter relay path on game end

pull/4131/merge
Thibault Duplessis 2018-03-13 10:08:48 -05:00
parent 9121d31a15
commit f709fdb58c
2 changed files with 12 additions and 5 deletions

View File

@ -113,15 +113,19 @@ private final class RelaySync(
tags = chapterNewTags,
uid = socketUid
) >> {
chapterNewTags.resultColor.isDefined ?? studyApi.analysisRequest(
studyId = study.id,
chapterId = chapter.id,
userId = "lichess"
)
chapterNewTags.resultColor.isDefined ?? onChapterEnd(study.id, chapter.id)
}
}
}
private def onChapterEnd(studyId: Study.Id, chapterId: Chapter.Id): Funit =
chapterRepo.setRelayPath(chapterId, Path.root) >>
studyApi.analysisRequest(
studyId = studyId,
chapterId = chapterId,
userId = "lichess"
)
private def createChapter(study: Study, game: RelayGame): Fu[Chapter] =
chapterRepo.nextOrderByStudy(study.id) flatMap { order =>
val name = {

View File

@ -71,6 +71,9 @@ final class ChapterRepo(coll: Coll) {
def setRelay(chapterId: Chapter.Id, relay: Chapter.Relay) =
coll.updateField($id(chapterId), "relay", relay).void
def setRelayPath(chapterId: Chapter.Id, path: Path) =
coll.updateField($id(chapterId), "relay.path", path).void
def setTagsFor(chapter: Chapter) =
coll.updateField($id(chapter.id), "tags", chapter.tags).void