From 72e81b8891ea21897d65b4abdaeb871307f39da2 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 10 Mar 2013 11:40:58 -0400 Subject: [PATCH] #315 fixes: newValue not accessible at scope, only remove duff history entries, not all --- migrations/20130307_remove_duff_histories.js | 6 +++--- src/app/scoring.coffee | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/migrations/20130307_remove_duff_histories.js b/migrations/20130307_remove_duff_histories.js index e10889e173..6211693a1f 100644 --- a/migrations/20130307_remove_duff_histories.js +++ b/migrations/20130307_remove_duff_histories.js @@ -1,14 +1,14 @@ -// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.js /** * Remove duff histories for dailies */ +// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.js db.users.find().forEach(function(user){ _.each(user.tasks, function(task, key){ - // remove task history if (task.type === "daily") { - task.history = [] + // remove busted history entries + task.history = _.filter(task.history, function(h){return !!h.value}) } }); diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 8664509ad5..1030ca133a 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -220,7 +220,7 @@ cron = (model) -> batch.set "tasks.#{taskObj.id}.value", newValue taskObj.history ?= [] - taskObj.history.push { date: +new Date, value: newValue || taskObj.value } + taskObj.history.push { date: +new Date, value: taskObj.value } batch.set "tasks.#{taskObj.id}.history", taskObj.history batch.set "tasks.#{taskObj.id}.completed", false else