remove duplicates on the server instead

Conflicts:
	lib/app/index.js
This commit is contained in:
Tyler Renelle
2012-10-18 00:05:45 -04:00
parent c76fe1424e
commit d5cc627c74
4 changed files with 7 additions and 8 deletions

View File

@@ -52,6 +52,9 @@ get('/:uid?', function(page, model, _arg, next) {
model.refList("_todoList", "_user.tasks", "_user.todoIds"); model.refList("_todoList", "_user.tasks", "_user.todoIds");
model.refList("_completedList", "_user.tasks", "_user.completedIds"); model.refList("_completedList", "_user.tasks", "_user.completedIds");
model.refList("_rewardList", "_user.tasks", "_user.rewardIds"); 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) { model.fn('_user._tnl', '_user.stats.lvl', function(lvl) {
return (lvl * 100) / 5; return (lvl * 100) / 5;
}); });

View File

@@ -252,9 +252,6 @@ score = function(taskId, direction, options) {
cron = function() { cron = function() {
var daysPassed, hpTally, lastCron, tallyTask, tasks, today, todoTally; 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(); today = new Date();
user.setNull('lastCron', today); user.setNull('lastCron', today);
lastCron = user.get('lastCron'); lastCron = user.get('lastCron');

View File

@@ -50,6 +50,10 @@ get '/:uid?', (page, model, {uid}, next) ->
model.refList "_completedList", "_user.tasks", "_user.completedIds" model.refList "_completedList", "_user.tasks", "_user.completedIds"
model.refList "_rewardList", "_user.tasks", "_user.rewardIds" 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 # Setup Model Functions
model.fn '_user._tnl', '_user.stats.lvl', (lvl) -> model.fn '_user._tnl', '_user.stats.lvl', (lvl) ->
# see https://github.com/lefnire/habitrpg/issues/4 # see https://github.com/lefnire/habitrpg/issues/4

View File

@@ -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) # At end of day, add value to all incomplete Daily & Todo tasks (further incentive)
# For incomplete Dailys, deduct experience # For incomplete Dailys, deduct experience
cron = -> 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() today = new Date()
user.setNull 'lastCron', today user.setNull 'lastCron', today
lastCron = user.get('lastCron') lastCron = user.get('lastCron')