diff --git a/src/app/index.coffee b/src/app/index.coffee index 937acc168a..7fa0a9ec7b 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -58,7 +58,10 @@ get '/', (page, model, next) -> model.ref '_user', user scoring.setModel(model) - scoring.cron(userObj) + try + scoring.cron userObj + catch e # always random errors, dont' crash the server + console.error e model.set userPath, userObj #unless _.isEqual(user.get(), userObj) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index ef2ed32763..b9cd1db345 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -196,10 +196,8 @@ cron = (userObj) -> lastCron = userObj.lastCron daysPassed = helpers.daysBetween(today, lastCron) if daysPassed > 0 - todoTally = 0 - userObj.history ?= {}; userObj.history.todos ?= []; userObj.history.exp ?= [] - # Tally each task + todoTally = 0 _.each userObj.tasks, (taskObj) -> #FIXME remove broken tasks if taskObj.id? # a task had a null id during cron, this should not be happening @@ -230,6 +228,7 @@ cron = (userObj) -> todoTally += absVal # Finished tallying + userObj.history ?= {}; userObj.history.todos ?= []; userObj.history.exp ?= [] userObj.history.todos.push { date: today, value: todoTally } # tally experience expTally = userObj.stats.exp