add shouldCron so we can test before running cron

This commit is contained in:
Tyler Renelle 2013-05-20 10:56:55 +01:00
parent 7805a2ba26
commit 9882e70026

View file

@ -308,6 +308,12 @@ updateStats = (user, newStats, paths) ->
gp = 0.0 if (!gp? or gp < 0) gp = 0.0 if (!gp? or gp < 0)
user.stats.gp = newStats.gp user.stats.gp = newStats.gp
obj.shouldCron = (user) ->
today = +new Date
lastCron = user.lastCron
return true if !lastCron? or lastCron is 'new' or moment(lastCron).isAfter(today)
return daysMissed = helpers.daysBetween(user.lastCron, today, user.preferences?.dayStart) > 0
### ###
At end of day, add value to all incomplete Daily & Todo tasks (further incentive) At end of day, add value to all incomplete Daily & Todo tasks (further incentive)
For incomplete Dailys, deduct experience For incomplete Dailys, deduct experience