chore: Add quest collection migration and temporary code to catch data inconsistencies

This commit is contained in:
Blade Barringer
2016-06-03 09:01:48 -05:00
parent 58cd634255
commit b3b437e593
4 changed files with 164 additions and 1 deletions

View File

@@ -589,6 +589,17 @@ schema.statics.processQuestProgress = async function processQuestProgress (user,
if (!_isOnQuest(user, progress, group)) return;
// TEMPORARY, remove once collection migration completes
if (typeof progress.collect === 'object') {
let totalItemsFound = _.reduce(progress.collect, (total, amount) => {
return total + amount;
}, 0);
progress.collect = totalItemsFound;
} else if (!progress.collect) {
progress.collect = 0;
}
let quest = shared.content.quests[group.quest.key];
if (!quest) return; // TODO should this throw an error instead?