From 9882e70026fab1b03bdcde9083e308d84d23fe03 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 20 May 2013 10:56:55 +0100 Subject: [PATCH] add shouldCron so we can test before running cron --- script/algos.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/algos.coffee b/script/algos.coffee index 7ab6e838d3..ea3faf7350 100644 --- a/script/algos.coffee +++ b/script/algos.coffee @@ -308,6 +308,12 @@ updateStats = (user, newStats, paths) -> gp = 0.0 if (!gp? or gp < 0) 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) For incomplete Dailys, deduct experience