broadcast manager get infinite broadcast analysis
parent
d6ad34517d
commit
06fcd65899
|
@ -62,7 +62,7 @@ final class Analyser(
|
|||
case _ =>
|
||||
import req._
|
||||
val sender = Work.Sender(req.userId, none, mod = false, system = false)
|
||||
limiter(sender, ignoreConcurrentCheck = true) flatMap { accepted =>
|
||||
(fuccess(req.unlimited) >>| limiter(sender, ignoreConcurrentCheck = true)) flatMap { accepted =>
|
||||
if (!accepted) logger.info(s"Study request declined: ${req.studyId}/${req.chapterId} by $sender")
|
||||
accepted ?? {
|
||||
val work = makeWork(
|
||||
|
|
|
@ -13,12 +13,10 @@ final private class Limiter(
|
|||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
def apply(sender: Work.Sender, ignoreConcurrentCheck: Boolean): Fu[Boolean] =
|
||||
if (sender.userId == User.lichessId) fuTrue
|
||||
else
|
||||
(fuccess(ignoreConcurrentCheck) >>| concurrentCheck(sender)) flatMap {
|
||||
case false => fuFalse
|
||||
case true => perDayCheck(sender)
|
||||
}
|
||||
(fuccess(ignoreConcurrentCheck) >>| concurrentCheck(sender)) flatMap {
|
||||
case false => fuFalse
|
||||
case true => perDayCheck(sender)
|
||||
}
|
||||
|
||||
private val RequestLimitPerIP = new lila.memo.RateLimit[IpAddress](
|
||||
credits = 60,
|
||||
|
|
|
@ -221,7 +221,8 @@ package fishnet {
|
|||
initialFen: Option[chess.format.FEN],
|
||||
variant: chess.variant.Variant,
|
||||
moves: List[Uci],
|
||||
userId: String
|
||||
userId: String,
|
||||
unlimited: Boolean
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,15 +7,17 @@ import scala.concurrent.duration._
|
|||
|
||||
import lila.analyse.{ Analysis, Info }
|
||||
import lila.hub.actorApi.fishnet.StudyChapterRequest
|
||||
import lila.security.Granter
|
||||
import lila.tree.Node.Comment
|
||||
import lila.user.User
|
||||
import lila.user.{ User, UserRepo }
|
||||
import lila.{ tree => T }
|
||||
|
||||
object ServerEval {
|
||||
|
||||
final class Requester(
|
||||
fishnet: lila.hub.actors.Fishnet,
|
||||
chapterRepo: ChapterRepo
|
||||
chapterRepo: ChapterRepo,
|
||||
userRepo: UserRepo
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
private val onceEvery = lila.memo.OnceEvery(5 minutes)
|
||||
|
@ -24,22 +26,29 @@ object ServerEval {
|
|||
chapter.serverEval.fold(true) { eval =>
|
||||
!eval.done && onceEvery(chapter.id.value)
|
||||
} ?? {
|
||||
chapterRepo.startServerEval(chapter) >>- {
|
||||
fishnet ! StudyChapterRequest(
|
||||
studyId = study.id.value,
|
||||
chapterId = chapter.id.value,
|
||||
initialFen = chapter.root.fen.some,
|
||||
variant = chapter.setup.variant,
|
||||
moves = chess.format
|
||||
.UciDump(
|
||||
moves = chapter.root.mainline.map(_.move.san),
|
||||
initialFen = chapter.root.fen.some,
|
||||
variant = chapter.setup.variant
|
||||
)
|
||||
.toOption
|
||||
.map(_.flatMap(chess.format.Uci.apply)) | List.empty,
|
||||
userId = userId
|
||||
)
|
||||
val unlimitedFu =
|
||||
fuccess(userId == User.lichessId) >>| userRepo
|
||||
.byId(userId)
|
||||
.map(_.exists(Granter(_.Relay)))
|
||||
unlimitedFu flatMap { unlimited =>
|
||||
chapterRepo.startServerEval(chapter) >>- {
|
||||
fishnet ! StudyChapterRequest(
|
||||
studyId = study.id.value,
|
||||
chapterId = chapter.id.value,
|
||||
initialFen = chapter.root.fen.some,
|
||||
variant = chapter.setup.variant,
|
||||
moves = chess.format
|
||||
.UciDump(
|
||||
moves = chapter.root.mainline.map(_.move.san),
|
||||
initialFen = chapter.root.fen.some,
|
||||
variant = chapter.setup.variant
|
||||
)
|
||||
.toOption
|
||||
.map(_.flatMap(chess.format.Uci.apply)) | List.empty,
|
||||
userId = userId,
|
||||
unlimited = unlimited
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue