just wrap scoring.cron in a try/catch, i'm sick of this

This commit is contained in:
Tyler Renelle 2013-01-21 00:23:48 -05:00
parent fb0d4d6d44
commit 2ddab98c82
2 changed files with 6 additions and 4 deletions

View file

@ -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)

View file

@ -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