Merge pull request #616 from MrConcept/fix

Fixed Daily History graphs
This commit is contained in:
Tyler Renelle 2013-03-10 08:22:43 -07:00
commit 0332ee7b48
3 changed files with 31 additions and 3 deletions

View file

@ -0,0 +1,28 @@
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.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);
}
})

View file

@ -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 "<i class='icon-star'></i> - #{rounded} XP", 'xp'
else if num > 0
statsNotification "<i class='icon-star'></i> + #{rounded} XP", 'xp'

View file

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