double stats-set

This commit is contained in:
Tyler Renelle 2013-02-04 02:55:29 -05:00
parent 8baa4cd8db
commit e4565c3f9b

View file

@ -139,14 +139,13 @@ score = (taskId, direction, times, batch, cron) ->
adjustvalue = if (taskObj.up==false or taskObj.down==false) then false else true
calculateDelta(adjustvalue)
# Add habit value to habit-history (if different)
historyEntry = { date: +new Date, value: value }
if (delta > 0) then addPoints() else subtractPoints()
taskObj.history ?= []
if taskObj.value != value
historyEntry = { date: +new Date, value: value }
taskObj.history.push historyEntry
batch.set "#{taskPath}.history", taskObj.history
when 'daily'
calculateDelta()
if cron? # cron
@ -179,7 +178,7 @@ score = (taskId, direction, times, batch, cron) ->
newStats = _.clone batch.obj().stats
_.each Object.keys(origStats), (key) -> obj.stats[key] = origStats[key]
batch.setStats(newStats)
batch.setStats()
# batch.setStats()
batch.commit()
return delta