move task corruption cleanup back to server to solve #803. This might

pose a problem for #769, but it seems that websockets / nginx version
was the real culprit there.
This commit is contained in:
Tyler Renelle 2013-04-10 17:30:50 -04:00
parent 4af8a91793
commit 761aeef8cf
2 changed files with 11 additions and 11 deletions

View file

@ -37,6 +37,17 @@ get '/', (page, model, params, next) ->
_.each ['habit', 'daily', 'todo', 'reward'], (type) ->
model.refList "_#{type}List", "_user.tasks", "_user.#{type}Ids"
# Cleanup some task-corruption (null tasks, rogue/invisible tasks, etc)
# Obviously none of this should be happening, but we'll stop-gap until we can find & fix
tasks = user.get('tasks')
_.each tasks, (task, key) ->
# Remove null tasks
unless task?.type?
user.del("tasks.#{key}")
# Put rogue tasks back into their lists. We could alternatively delete them (they're rogue because they weren't properly deleted), but that's dangerous
else if user.get("#{task.type}Ids").indexOf(task.id) is -1
user.push "#{task.type}Ids", task.id
page.render()
# ========== CONTROLLER FUNCTIONS ==========

View file

@ -261,17 +261,6 @@ cron = (model) ->
daysPassed = helpers.daysBetween(user.get('lastCron'), today, user.get('preferences.dayStart'))
if daysPassed > 0
# Cleanup some task-corruption (null tasks, rogue/invisible tasks, etc)
# Obviously none of this should be happening, but we'll stop-gap until we can find & fix
tasks = user.get('tasks')
_.each tasks, (task, key) ->
# Remove null tasks
unless task?.type?
user.del("tasks.#{key}")
# Put rogue tasks back into their lists. We could alternatively delete them (they're rogue because they weren't properly deleted), but that's dangerous
else if user.get("#{task.type}Ids").indexOf(task.id) is -1
user.push "#{task.type}Ids", task.id
batch = new character.BatchUpdate(model)
batch.startTransaction()
batch.set 'lastCron', today