broadcast: automatically analyse completed games

pull/4111/head
Thibault Duplessis 2018-03-08 20:30:14 -05:00
parent d672534ae6
commit bb59f2473a
3 changed files with 17 additions and 9 deletions

View File

@ -57,7 +57,7 @@ final class Analyser(
case true => fuccess(false)
case _ => {
import req._
val sender = Work.Sender(req.userId, none, false, false)
val sender = Work.Sender(req.userId, none, false, system = req.userId == "lichess")
limiter(sender) flatMap { accepted =>
accepted ?? {
val work = makeWork(

View File

@ -38,7 +38,7 @@ private final class Limiter(
private val maxPerDay = 30
private def perDayCheck(sender: Work.Sender) = sender match {
case Work.Sender(_, _, mod, system) if (mod || system) => fuccess(true)
case Work.Sender(_, _, mod, system) if mod || system => fuccess(true)
case Work.Sender(Some(userId), _, _, _) => requesterApi.countToday(userId) map (_ < maxPerDay)
case Work.Sender(_, Some(ip), _, _) => fuccess {
RequestLimitPerIP(ip, cost = 1)(true)

View File

@ -105,13 +105,21 @@ private final class RelaySync(
val chapterNewTags = tags.value.foldLeft(chapter.tags) {
case (chapterTags, tag) => PgnTags(chapterTags + tag)
}
(chapterNewTags != chapter.tags) ?? studyApi.setTags(
userId = chapter.ownerId,
studyId = study.id,
chapterId = chapter.id,
tags = chapterNewTags,
uid = socketUid
)
(chapterNewTags != chapter.tags) ?? {
studyApi.setTags(
userId = chapter.ownerId,
studyId = study.id,
chapterId = chapter.id,
tags = chapterNewTags,
uid = socketUid
) >> {
chapterNewTags.resultColor.isDefined ?? studyApi.analysisRequest(
studyId = study.id,
chapterId = chapter.id,
userId = "lichess"
)
}
}
}
private def createChapter(study: Study, game: RelayGame): Fu[Chapter] =