mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-17 11:18:52 +00:00
handle missing crons @WIP
This commit is contained in:
parent
3fdd43aeee
commit
aca5ad4ca7
2 changed files with 10 additions and 8 deletions
5
migrations/20130128_add_missing_crons.js
Normal file
5
migrations/20130128_add_missing_crons.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
db.users.update(
|
||||
{ lastCron: { $exists: false} },
|
||||
{ $set: { lastCron: +new Date } },
|
||||
{ multi: true }
|
||||
);
|
||||
|
|
@ -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)
|
||||
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)
|
||||
Loading…
Reference in a new issue