mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
28 lines
No EOL
667 B
JavaScript
28 lines
No EOL
667 B
JavaScript
/**
|
|
* Remove duff histories for dailies
|
|
*/
|
|
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.js
|
|
db.users.find().forEach(function(user){
|
|
|
|
|
|
_.each(user.tasks, function(task, key){
|
|
if (task.type === "daily") {
|
|
// remove busted history entries
|
|
task.history = _.filter(task.history, function(h){return !!h.value})
|
|
}
|
|
});
|
|
|
|
try {
|
|
db.users.update(
|
|
{_id:user._id},
|
|
{$set:
|
|
{
|
|
'tasks' : user.tasks
|
|
}
|
|
},
|
|
{multi:true}
|
|
);
|
|
} catch(e) {
|
|
print(e);
|
|
}
|
|
}) |