From ff86fb91e35612dd4dfebfec4084254708a8ffb4 Mon Sep 17 00:00:00 2001 From: zkldi Date: Tue, 25 May 2021 15:16:26 +0100 Subject: [PATCH] Finally synchronise everything and close #126 --- .../scripts/__JSON-TO-KTDB/iidx/diff-sync.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/server/scripts/__JSON-TO-KTDB/iidx/diff-sync.ts b/server/scripts/__JSON-TO-KTDB/iidx/diff-sync.ts index 66230e6ba..8d634840c 100644 --- a/server/scripts/__JSON-TO-KTDB/iidx/diff-sync.ts +++ b/server/scripts/__JSON-TO-KTDB/iidx/diff-sync.ts @@ -67,20 +67,32 @@ const logger = CreateLogCtx("diff.ts"); } if (chart.data.notecount !== data.notecounts[diff]) { + if ( + data.notecounts[diff] === undefined || + Math.abs(chart.data.notecount - data.notecounts[diff]!) > 2 + ) { + logger.error( + `Significant Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}] - skipping.` + ); + // continue; + } + logger.warn( `Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}]` ); - await db.charts.iidx.update( - { - _id: chart._id, - }, - { - $set: { - "data.notecount": data.notecounts[diff], + if (options.sync) { + await db.charts.iidx.update( + { + _id: chart._id, }, - } - ); + { + $set: { + "data.notecount": data.notecounts[diff], + }, + } + ); + } } } }