From 50c506922498a28a780e7e66a3e5cf6f4bcdf984 Mon Sep 17 00:00:00 2001 From: Philip How Date: Fri, 8 Mar 2013 00:10:11 +0000 Subject: [PATCH 1/3] notifications tweak and history fix --- src/app/browser.coffee | 2 +- src/app/scoring.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index fcc32647ee..55a6c9229f 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -178,7 +178,7 @@ setupGrowlNotifications = (model) -> # unless silent num = captures - args rounded = Math.abs(num.toFixed(1)) - if num < 0 and num > -100 # TODO fix hackey negative notification supress + if num < 0 and num > -50 # TODO fix hackey negative notification supress statsNotification " - #{rounded} XP", 'xp' else if num > 0 statsNotification " + #{rounded} XP", 'xp' diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 5cc5a8428c..8664509ad5 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: value } + taskObj.history.push { date: +new Date, value: newValue || taskObj.value } batch.set "tasks.#{taskObj.id}.history", taskObj.history batch.set "tasks.#{taskObj.id}.completed", false else @@ -229,7 +229,7 @@ cron = (model) -> todoTally += absVal else if type is 'habit' # slowly reset 'onlies' value to 0 if taskObj.up==false or taskObj.down==false - if Math.abs(taskObj.value) < 0.02 + if Math.abs(taskObj.value) < 0.1 batch.set "tasks.#{taskObj.id}.value", 0 else batch.set "tasks.#{taskObj.id}.value", taskObj.value / 2 From 24c767776495ae991a15df1894e8185330a4057b Mon Sep 17 00:00:00 2001 From: Philip How Date: Fri, 8 Mar 2013 00:20:46 +0000 Subject: [PATCH 2/3] Migration script for removing old dailies histories --- migrations/20130307_remove_duff_histories.js | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 migrations/20130307_remove_duff_histories.js diff --git a/migrations/20130307_remove_duff_histories.js b/migrations/20130307_remove_duff_histories.js new file mode 100644 index 0000000000..a8475f6adb --- /dev/null +++ b/migrations/20130307_remove_duff_histories.js @@ -0,0 +1,29 @@ +// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js + +/** + * Remove duff histories for dailies + */ +db.users.find().forEach(function(user){ + + + _.each(user.tasks, function(task, key){ + // remove task history + if (task.type === "daily") { + task.history = [] + } + }); + + try { + db.users.update( + {_id:user._id}, + {$set: + { + 'tasks' : user.tasks + } + }, + {multi:true} + ); + } catch(e) { + print(e); + } +}) \ No newline at end of file From b6a7d63c21c6a63c19b3d7efe47d2863b47a7b4d Mon Sep 17 00:00:00 2001 From: Philip How Date: Fri, 8 Mar 2013 00:23:08 +0000 Subject: [PATCH 3/3] changed migration comment --- migrations/20130307_remove_duff_histories.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migrations/20130307_remove_duff_histories.js b/migrations/20130307_remove_duff_histories.js index a8475f6adb..e10889e173 100644 --- a/migrations/20130307_remove_duff_histories.js +++ b/migrations/20130307_remove_duff_histories.js @@ -1,5 +1,4 @@ -// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js - +// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.js /** * Remove duff histories for dailies */