diff --git a/migrations/20130128_add_missing_crons.js b/migrations/20130128_add_missing_crons.js new file mode 100644 index 0000000000..1a4c919cc2 --- /dev/null +++ b/migrations/20130128_add_missing_crons.js @@ -0,0 +1,5 @@ +db.users.update( + { lastCron: { $exists: false} }, + { $set: { lastCron: +new Date } }, + { multi: true } +); \ No newline at end of file diff --git a/src/server/cron.coffee b/src/server/cron.coffee index 5ea286c2c4..931ba3e3c7 100644 --- a/src/server/cron.coffee +++ b/src/server/cron.coffee @@ -31,11 +31,8 @@ module.exports.deleteStaleAccounts = -> collection.findEach un_registered, (err, user) -> throw err if err return unless user? #why does this happen sometimes? - unless user.lastCron - removeAccount(collection, user._id) - return - - lastCron = new Date(user.lastCron) - diff = Math.abs(moment(today).sod().diff(moment(lastCron).sod(), "days")) - if diff > 30 - removeAccount(collection, user._id) \ No newline at end of file + if !!user.lastCron # for now ignore missing crons, still looking into why this is happening + lastCron = new Date(user.lastCron) + diff = Math.abs(moment(today).sod().diff(moment(lastCron).sod(), "days")) + if diff > 30 + removeAccount(collection, user._id) \ No newline at end of file