log analysis anomalies
This commit is contained in:
parent
db398d5549
commit
cfff341c5e
|
@ -44,7 +44,7 @@ object Analyse extends LilaController {
|
|||
}
|
||||
|
||||
def postAnalysis(id: String) = Action(parse.text) { req =>
|
||||
env.analyser.complete(id, req.body) >>- {
|
||||
env.analyser.complete(id, req.body, req.remoteAddress) >>- {
|
||||
Env.hub.socket.round ! Tell(id, AnalysisAvailable)
|
||||
}
|
||||
Ok
|
||||
|
|
|
@ -57,7 +57,7 @@ final class Analyser(
|
|||
}
|
||||
}
|
||||
case Some(game) => fufail(s"[analysis] game $id is not analysable")
|
||||
case _ => fufail(s"[analysis] game $id is missing")
|
||||
case _ => fufail(s"[analysis] game $id is missing")
|
||||
}
|
||||
|
||||
get(id) flatMap {
|
||||
|
@ -65,24 +65,27 @@ final class Analyser(
|
|||
}
|
||||
}
|
||||
|
||||
def complete(id: String, data: String) =
|
||||
def complete(id: String, data: String, from: String) =
|
||||
$find.byId[Game](id) zip get(id) zip (GameRepo initialFen id) flatMap {
|
||||
case ((Some(game), Some(a1)), initialFen) => Info decodeList data match {
|
||||
case None => fufail(s"[analysis] $data")
|
||||
case Some(infos) => chess.Replay(game.pgnMoves, initialFen, game.variant).fold(
|
||||
fufail(_),
|
||||
replay => UciToPgn(replay, a1 complete infos) match {
|
||||
case (analysis, errors) =>
|
||||
errors foreach { e => logwarn(s"[analysis UciToPgn] $id $e") }
|
||||
if (analysis.valid) {
|
||||
indexer ! InsertGame(game)
|
||||
AnalysisRepo.done(id, analysis) >>- {
|
||||
modActor ! actorApi.AnalysisReady(game, analysis)
|
||||
} >>- GameRepo.setAnalysed(game.id) inject analysis
|
||||
}
|
||||
else fufail(s"[analysis] invalid $id")
|
||||
})
|
||||
}
|
||||
case ((Some(game), Some(a1)), initialFen) if game.analysable =>
|
||||
Info decodeList data match {
|
||||
case None => fufail(s"[analysis] $data")
|
||||
case Some(infos) => chess.Replay(game.pgnMoves, initialFen, game.variant).fold(
|
||||
fufail(_),
|
||||
replay => UciToPgn(replay, a1 complete infos) match {
|
||||
case (analysis, errors) =>
|
||||
errors foreach { e => logwarn(s"[analysis UciToPgn] $id $e") }
|
||||
if (analysis.valid) {
|
||||
if (analysis.emptyRatio >= 1d / 10)
|
||||
logwarn(s"Analysis $id from $from has ${analysis.nbEmptyInfos} empty infos out of {$analysis.infos.size}")
|
||||
indexer ! InsertGame(game)
|
||||
AnalysisRepo.done(id, analysis) >>- {
|
||||
modActor ! actorApi.AnalysisReady(game, analysis)
|
||||
} >>- GameRepo.setAnalysed(game.id) inject analysis
|
||||
}
|
||||
else fufail(s"[analysis] invalid $id")
|
||||
})
|
||||
}
|
||||
case _ => fufail(s"[analysis] complete non-existing $id")
|
||||
} addFailureEffect {
|
||||
_ => AnalysisRepo remove id
|
||||
|
|
|
@ -44,6 +44,9 @@ case class Analysis(
|
|||
def valid = encodeInfos.replace(";", "").nonEmpty
|
||||
|
||||
def stalled = (done && !valid) || (!done && date.isBefore(DateTime.now minusHours 2))
|
||||
|
||||
def nbEmptyInfos = infos.count(_.isEmpty)
|
||||
def emptyRatio: Double = nbEmptyInfos.toDouble / infos.size
|
||||
}
|
||||
|
||||
object Analysis {
|
||||
|
|
|
@ -32,6 +32,8 @@ case class Info(
|
|||
def mateComment: Option[String] = mate map { m => s"Mate in ${math.abs(m)}" }
|
||||
def evalComment: Option[String] = scoreComment orElse mateComment
|
||||
|
||||
def isEmpty = score.isEmpty && mate.isEmpty
|
||||
|
||||
override def toString = s"Info $color [$ply] ${score.fold("?")(_.showPawns)} ${mate | 0} ${variation.mkString(" ")}"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue