Skip to content

Commit

Permalink
tweak and simplify insight indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jan 29, 2023
1 parent 325b1a8 commit 20614f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/insight/src/main/InsightIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final private class InsightIndexer(
)(using Executor, akka.actor.Scheduler, akka.stream.Materializer):

private val workQueue =
lila.hub.AsyncActorSequencer(maxSize = Max(256), timeout = 2 minutes, name = "insightIndexer")
lila.hub.AsyncActorSequencer(maxSize = Max(256), timeout = 1 minute, name = "insightIndexer")

def all(user: User): Funit =
workQueue {
Expand Down
22 changes: 8 additions & 14 deletions modules/insight/src/main/PovToEntry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ final private class PovToEntry(
private def convert(from: RichPov): Option[InsightEntry] =
import from.*
import pov.game
for {
for
myId <- pov.player.userId
perfType <- game.perfType
myRating = pov.player.stableRating
opRating = pov.opponent.stableRating
opening = findOpening(from)
} yield InsightEntry(
yield InsightEntry(
id = InsightEntry povToId pov,
userId = myId,
color = pov.color,
Expand All @@ -202,11 +202,11 @@ final private class PovToEntry(
opponentCastling = Castling.fromMoves(game sansOf !pov.color),
moves = makeMoves(from),
queenTrade = queenTrade(from),
result = game.winnerUserId match {
result = game.winnerUserId match
case None => Result.Draw
case Some(u) if u == myId => Result.Win
case _ => Result.Loss
},
,
termination = Termination fromStatus game.status,
ratingDiff = ~pov.player.ratingDiff,
analysed = analysis.isDefined,
Expand All @@ -215,13 +215,7 @@ final private class PovToEntry(
)

private def findOpening(from: RichPov): Option[SimpleOpening] =
from.pov.game.variant.standard ??
from.situations.tail.view
.takeWhile(_.board.actors.sizeIs >= 20)
.foldRight(none[SimpleOpening]) {
case (sit, None) =>
OpeningDb
.findByOpeningFen(Fen writeOpening sit)
.flatMap(SimpleOpening.apply)
case (_, found) => found
}
from.pov.game.variant.standard ?? OpeningDb
.searchInSituations(from.situations.toList)
.map(_.opening)
.flatMap(SimpleOpening.apply)
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Dependencies {
val scalalib = "com.github.ornicar" %% "scalalib" % "9.1.1"
val hasher = "com.roundeights" %% "hasher" % "1.3.1"
val jodaTime = "joda-time" % "joda-time" % "2.12.2"
val chess = "org.lichess" %% "scalachess" % "14.2.1"
val chess = "org.lichess" %% "scalachess" % "14.2.2"
val compression = "org.lichess" %% "compression" % "1.8"
val maxmind = "com.maxmind.geoip2" % "geoip2" % "3.0.2"
val prismic = "io.prismic" %% "scala-kit" % "1.2.19_lila-1"
Expand Down

0 comments on commit 20614f0

Please sign in to comment.