fix study multiboard

pull/8099/head
Thibault Duplessis 2021-02-05 09:58:27 +01:00
parent ee87d1a264
commit 15b05b02c9
1 changed files with 9 additions and 14 deletions

View File

@ -39,7 +39,7 @@ final class StudyMultiBoard(
private val playingSelector = $doc("tags" -> "Result:*", "root.n.0" $exists true)
def fetch(studyId: Study.Id, page: Int, playing: Boolean): Fu[Paginator[ChapterPreview]] =
private def fetch(studyId: Study.Id, page: Int, playing: Boolean): Fu[Paginator[ChapterPreview]] =
Paginator[ChapterPreview](
new ChapterPreviewAdapter(studyId, playing),
currentPage = page,
@ -53,9 +53,6 @@ final class StudyMultiBoard(
def nbResults: Fu[Int] = chapterRepo.coll(_.countSel(selector))
/* TODO fix
* printjson(db.study_chapter_flat.aggregate([{$match:{studyId:'6IzKWsfb'}},{$project:{root:{$objectToArray:'$root'}}},{$unwind:'$root'},{$project:{'root.v.f':1,size:{$strLenBytes:'$root.k'}}},{$sort:{size:-1}},{$limit:1}]).toArray())
* */
def slice(offset: Int, length: Int): Fu[Seq[ChapterPreview]] =
chapterRepo
.coll {
@ -68,16 +65,14 @@ final class StudyMultiBoard(
Project(
$doc(
"comp" -> $doc(
// "$function" -> $doc(
// "lang" -> "js",
// "args" -> $arr("$root", "$tags"),
// "body" -> """function(node, tags) { tags = tags.filter(t => t.startsWith('White') || t.startsWith('Black') || t.startsWith('Result')); if (tags.length) while(child = node.n[0]) { node = child }; return {node:{fen:node.f,uci:node.u},tags} }"""
// )
// {node:{fen:node.f,uci:node.u},tags}
"node" -> $doc(
"fen" -> "$root._.f"
),
"tags" -> true
"$function" -> $doc(
"lang" -> "js",
"args" -> $arr("$root", "$tags"),
"body" -> """function(root, tags) {
|tags = tags.filter(t => t.startsWith('White') || t.startsWith('Black') || t.startsWith('Result'));
|const node = tags.length ? Object.keys(root).reduce((acc, i) => (root[i].p > acc.p) ? root[i] : acc, root['_']) : root['_'];
|return {node:{fen:node.f,uci:node.u},tags} }""".stripMargin
)
),
"orientation" -> "$setup.orientation",
"name" -> true