Removed schemaUpdate code for _todoList <-> _completedList update.

revert here to see the code
This commit is contained in:
Tyler Renelle 2012-07-28 16:43:16 -04:00
parent 3895d0610a
commit 86dffb87a6
3 changed files with 6 additions and 51 deletions

View file

@ -21,30 +21,4 @@ module.exports.userSchema = userSchema = {
rewardIds: []
};
module.exports.updateSchema = function(model) {
var completedIds, id, index, task, todoIds, uid, user, userObj, _ref, _ref1, _results;
_ref = model.get('users');
_results = [];
for (uid in _ref) {
userObj = _ref[uid];
user = model.at("users." + uid);
user.set('completedIds', []);
completedIds = user.get('completedIds');
todoIds = user.get('todoIds');
_ref1 = user.get('tasks');
for (id in _ref1) {
task = _ref1[id];
if (task.type === 'todo' && task.completed === true) {
if ((index = todoIds.indexOf(id)) !== -1) {
todoIds.splice(index, 1);
}
if ((index = completedIds.indexOf(id)) === -1) {
completedIds.push(id);
}
}
}
user.set('todoIds', todoIds);
_results.push(user.set('completedIds', completedIds));
}
return _results;
};
module.exports.updateSchema = function(model) {};

View file

@ -1,7 +1,7 @@
{
"name": "habitrpg",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "0.0.0-66",
"version": "0.0.0-76",
"main": "./server.js",
"dependencies": {
"derby": "git://github.com/codeparty/derby#master",

View file

@ -11,26 +11,7 @@ module.exports.userSchema = userSchema = {
}
module.exports.updateSchema = (model) ->
for uid,userObj of model.get('users')
user = model.at("users.#{uid}")
user.set 'completedIds', []
# schema = jQuery.extend(true, {}, userSchema)
# # add to schema if user doesn't have these elements
# _.each schema, (val,key) ->
# user.set(key,val) unless user.get(key)
# _todoList <-> _completedList transfering code update
completedIds = user.get('completedIds')
todoIds = user.get('todoIds')
for id,task of user.get('tasks')
if task.type=='todo' and task.completed==true
# if in todoList but shouldn't be, remove it
if (index = todoIds.indexOf(id)) != -1
todoIds.splice(index, 1)
# if not in completedList but should be, add it
if (index = completedIds.indexOf(id)) == -1
completedIds.push id
user.set 'todoIds', todoIds
user.set 'completedIds', completedIds
# removed old update code, dangerous to run twice.
# I'm placing db-update code in this function while still in dev, then running
# once on the server, then removing the code. FIXME figure out something better
return