Skip to content

Commit

Permalink
faster fetch games analysis during assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Mar 11, 2018
1 parent aa72d2f commit b89f4f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions modules/analyse/src/main/AnalysisRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ object AnalysisRepo {

def byId(id: ID): Fu[Option[Analysis]] = coll.byId[Analysis](id)

def byGame(game: Game): Fu[Option[Analysis]] =
game.metadata.analysed ?? byId(game.id)

def byIds(ids: Seq[ID]): Fu[Seq[Option[Analysis]]] =
coll.optionsByOrderedIds[Analysis, Analysis.ID](ids)(_.id)

Expand Down
7 changes: 3 additions & 4 deletions modules/mod/src/main/AssessApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import lila.db.dsl._
import lila.evaluation.Statistics
import lila.evaluation.{ AccountAction, Analysed, PlayerAssessment, PlayerAggregateAssessment, PlayerFlags, PlayerAssessments, Assessible }
import lila.game.{ Game, Player, GameRepo, Source, Pov }
import lila.user.{ User, UserRepo }
import lila.report.{ SuspectId, ModId }
import lila.user.{ User, UserRepo }

import reactivemongo.api.ReadPreference
import reactivemongo.bson._
Expand Down Expand Up @@ -81,9 +81,8 @@ final class AssessApi(
def refreshAssessByUsername(username: String): Funit = withUser(username) { user =>
(GameRepo.gamesForAssessment(user.id, 100) flatMap { gs =>
(gs map { g =>
AnalysisRepo.byId(g.id) flatMap {
case Some(a) => onAnalysisReady(g, a, false)
case _ => funit
AnalysisRepo.byGame(g) flatMap {
_ ?? { onAnalysisReady(g, _, false) }
}
}).sequenceFu.void
}) >> assessUser(user.id)
Expand Down

0 comments on commit b89f4f7

Please sign in to comment.