do not delete completed todos that belongs to a challenge

This commit is contained in:
Matteo Pagliazzi
2016-01-06 12:25:53 +01:00
parent 3a6d7bd466
commit 2b2dcfe7ce

View File

@@ -34,6 +34,7 @@ export default function cronMiddleware (req, res, next) {
cron({user, tasksByType, now, daysMissed, analytics});
// Clean completed todos - 30 days for free users, 90 for subscribers
// Do not delete challenges completed todos TODO unless the task is broken?
Task.remove({
userId: user._id,
type: 'todo',
@@ -41,6 +42,7 @@ export default function cronMiddleware (req, res, next) {
dateCompleted: {
$lt: moment(now).subtract(user.isSubscribed() ? 90 : 30, 'days'),
},
'challenge.id': {$exists: false},
}).exec(); // TODO catch error or at least log it
let ranCron = user.isModified();