no longer preload study destinations, as to leverage eval cache

This commit is contained in:
Thibault Duplessis 2017-02-01 12:55:02 +01:00
parent a4290783da
commit 28103c670b
3 changed files with 4 additions and 16 deletions

View file

@ -58,7 +58,7 @@ object Practice extends LilaController {
case (baseData, studyJson) =>
val analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder(chapter.root, chapter.setup.variant)
lila.study.TreeBuilder(chapter.root)
},
"practiceGoal" -> lila.practice.PracticeGoal(chapter))
(analysis, studyJson)

View file

@ -99,7 +99,7 @@ object Study extends LilaController {
study = studyJson,
analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder(chapter.root, chapter.setup.variant)
lila.study.TreeBuilder(chapter.root)
}))
res <- negotiate(
html = for {
@ -176,7 +176,7 @@ object Study extends LilaController {
import lila.tree.Node.partitionTreeJsonWriter
val analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder.makeRoot(chapter.root)
lila.study.TreeBuilder(chapter.root)
})
val data = lila.study.JsonView.JsData(
study = studyJson,

View file

@ -5,19 +5,7 @@ import lila.tree
object TreeBuilder {
private val initialStandardDests = chess.Game(chess.variant.Standard).situation.destinations
def apply(root: Node.Root, variant: chess.variant.Variant) = {
val dests =
if (variant.standard && root.fen.value == chess.format.Forsyth.initial) initialStandardDests
else {
val sit = chess.Game(variant.some, root.fen.value.some).situation
sit.playable(false) ?? sit.destinations
}
makeRoot(root).copy(dests = dests.some)
}
def makeRoot(root: Node.Root) = tree.Root(
def apply(root: Node.Root) = tree.Root(
ply = root.ply,
fen = root.fen.value,
check = root.check,