mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
don't delete on invalid cron, but undefined cron. still thinking on this
This commit is contained in:
parent
c625458ce3
commit
0e8d4b4f1f
1 changed files with 7 additions and 7 deletions
|
|
@ -22,20 +22,20 @@ module.exports.deleteStaleAccounts = ->
|
|||
|
||||
today = +new Date
|
||||
|
||||
isValidDate = (d) ->
|
||||
return false if Object::toString.call(d) isnt "[object Date]"
|
||||
not isNaN(d.getTime())
|
||||
# isValidDate = (d) ->
|
||||
# return false if Object::toString.call(d) isnt "[object Date]"
|
||||
# not isNaN(d.getTime())
|
||||
|
||||
removeAccount = (collection, id) -> collection.remove {_id: id}, (err, res) -> throw err if err
|
||||
|
||||
collection.findEach un_registered, (err, user) ->
|
||||
throw err if err
|
||||
return unless user? #why does this happen sometimes?
|
||||
lastCron = new Date(user.lastCron)
|
||||
if !isValidDate(lastCron)
|
||||
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 > 15
|
||||
removeAccount(collection, user._id)
|
||||
return
|
||||
removeAccount(collection, user._id)
|
||||
Loading…
Reference in a new issue