mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-31 15:09:32 +00:00
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:
parent
4af8a91793
commit
761aeef8cf
2 changed files with 11 additions and 11 deletions
|
|
@ -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 ==========
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue