detect malformed study chapters

This commit is contained in:
Thibault Duplessis 2018-02-09 09:59:19 -05:00
parent 9fae708011
commit 7a06225b32

View file

@ -0,0 +1,18 @@
rs.slaveOk();
var depth, maxDepth = 900;
function depthOf(branch) { return 2 + Math.max(...(branch.n || []).map(depthOf),0); }
function urlOf(chap) {
var study = db.study.findOne({_id:chap.studyId});
return `https://lichess.org/study/${study._id}/${chap._id} by ${study.ownerId}`;
}
db.study_chapter.find().forEach(chap => {
try {
depth = depthOf(chap.root);
if (depth > maxDepth) print(`${urlOf(chap)} ${depth}`);
} catch(e) {
print(`${urlOf(chap)} ${e}`);
}
})