spells: searing brightness should not affect challenge tasks (#8427)

* spells: searing brightness should not affect challenge tasks

* fixed other incorrect group vs challenge task exclusions

* fixed /tasks/clearCompletedTodos test

didn't account for the new group task

* fixed comment omission in tasks/clearCompletedTodos
This commit is contained in:
Jaka Kranjc
2017-01-24 11:14:25 +01:00
committed by Matteo Pagliazzi
parent 86d65956d9
commit 8c8af83dfc
3 changed files with 68 additions and 28 deletions
+14 -6
View File
@@ -896,16 +896,24 @@ api.clearCompletedTodos = {
let user = res.locals.user;
// Clear completed todos
// Do not delete challenges completed todos unless the task is broken
// Do not delete completed todos from challenges or groups, unless the task is broken
await Tasks.Task.remove({
userId: user._id,
type: 'todo',
completed: true,
$or: [
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
$and: [ // exclude challenge and group tasks
{
$or: [
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
],
},
{
$or: [
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
},
],
}).exec();