no more 'new' deafult lastCron, set it to +new Date()

This commit is contained in:
Tyler Renelle
2013-08-24 19:07:42 -04:00
parent 6aa9483a0b
commit 9af5d2d29b
2 changed files with 4 additions and 19 deletions
+2
View File
@@ -355,6 +355,7 @@ obj.cron = (user, options={}) ->
[paths, now] = [options.paths || {}, +options.now || +new Date]
# New user (!lastCron, lastCron==new) or it got busted somehow, maybe they went to a different timezone
# FIXME move this to pre-save in mongoose
if !user.lastCron? or user.lastCron is 'new' or moment(user.lastCron).isAfter(now)
user.lastCron = now; paths['lastCron'] = true
return
@@ -371,6 +372,7 @@ obj.cron = (user, options={}) ->
# Tally each task
todoTally = 0
user.todos.concat(user.dailys).forEach (task) ->
return unless task
{id, type, completed, repeat} = task
# Deduct experience for missed Daily tasks, but not for Todos (just increase todo's value)
unless completed