mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
chore: Add quest collection migration and temporary code to catch data inconsistencies
This commit is contained in:
@@ -392,6 +392,17 @@ api.scoreTask = {
|
||||
|
||||
let wasCompleted = task.completed;
|
||||
|
||||
// TEMPORARY, remove once collection migration completes
|
||||
if (typeof user.party.quest.progress.collect === 'object') {
|
||||
let totalItemsFound = _.reduce(user.party.quest.progress.collect, (total, amount) => {
|
||||
return total + amount;
|
||||
}, 0);
|
||||
|
||||
user.party.quest.progress.collect = totalItemsFound;
|
||||
} else if (!user.party.quest.progress.collect) {
|
||||
user.party.quest.progress.collect = 0;
|
||||
}
|
||||
|
||||
let [delta] = common.ops.scoreTask({task, user, direction}, req);
|
||||
// Drop system (don't run on the client, as it would only be discarded since ops are sent to the API, not the results)
|
||||
if (direction === 'up') user.fns.randomDrop({task, delta}, req);
|
||||
|
||||
Reference in New Issue
Block a user