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
+4 -23
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