From 2ddab98c82a2e9bfb0e3273ed0ecd8ca500a9063 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 21 Jan 2013 00:23:48 -0500 Subject: [PATCH] just wrap scoring.cron in a try/catch, i'm sick of this --- src/app/index.coffee | 5 ++++- src/app/scoring.coffee | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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