From d5cc627c7472ee37bf35d217336eefad7da1956c Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Thu, 18 Oct 2012 00:05:45 -0400 Subject: [PATCH] remove duplicates on the server instead Conflicts: lib/app/index.js --- lib/app/index.js | 3 +++ lib/app/scoring.js | 3 --- src/app/index.coffee | 4 ++++ src/app/scoring.coffee | 5 ----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/app/index.js b/lib/app/index.js index f3544c2c65..0e56dbc7be 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -52,6 +52,9 @@ get('/:uid?', function(page, model, _arg, next) { model.refList("_todoList", "_user.tasks", "_user.todoIds"); model.refList("_completedList", "_user.tasks", "_user.completedIds"); model.refList("_rewardList", "_user.tasks", "_user.rewardIds"); + _.each(['habitIds', 'dailyIds', 'todoIds', 'rewardIds'], function(path) { + return user.set(path, _.uniq(user.get(path), true)); + }); model.fn('_user._tnl', '_user.stats.lvl', function(lvl) { return (lvl * 100) / 5; }); diff --git a/lib/app/scoring.js b/lib/app/scoring.js index 4399c733f2..25405fdb8a 100644 --- a/lib/app/scoring.js +++ b/lib/app/scoring.js @@ -252,9 +252,6 @@ score = function(taskId, direction, options) { cron = function() { var daysPassed, hpTally, lastCron, tallyTask, tasks, today, todoTally; - _.each(['habitIds', 'dailyIds', 'todoIds', 'rewardIds'], function(path) { - return user.set(path, _.uniq(user.get(path))); - }); today = new Date(); user.setNull('lastCron', today); lastCron = user.get('lastCron'); diff --git a/src/app/index.coffee b/src/app/index.coffee index 27b1ab741b..c87680d30c 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -49,6 +49,10 @@ get '/:uid?', (page, model, {uid}, next) -> model.refList "_todoList", "_user.tasks", "_user.todoIds" model.refList "_completedList", "_user.tasks", "_user.completedIds" model.refList "_rewardList", "_user.tasks", "_user.rewardIds" + + # FIXME temporary hack to remove duplicates. Need to figure out why they're being produced + _.each ['habitIds','dailyIds','todoIds','rewardIds'], (path) -> + user.set path, _.uniq(user.get(path), true) # Setup Model Functions model.fn '_user._tnl', '_user.stats.lvl', (lvl) -> diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 1edc8eddcd..d11292e403 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -210,11 +210,6 @@ score = (taskId, direction, options={cron:false, times:1}) -> # At end of day, add value to all incomplete Daily & Todo tasks (further incentive) # For incomplete Dailys, deduct experience cron = -> - - # FIXME temporary hack to remove duplicates. Need to figure out why they're being produced - _.each ['habitIds','dailyIds','todoIds','rewardIds'], (path) -> - user.set path, _.uniq(user.get(path)) - today = new Date() user.setNull 'lastCron', today lastCron = user.get('lastCron')