Simplify processing logic
Simplifies the logic by reducing the number of sync operations to 2 (instead of 3). Items are only added to the queue if a process is already running, and they are popped off the queue when the task finishes.
Also ensures that the processing should work even if the mongo document does not have any queue
or sync_counter
attribute set (for example when they have been migrated from v0).
Also restricts the resetting of existing entries when reprocessing to only the ones that actually have status processing, as it should not be necessary to reset any other entries (this should anyway really only happen if something has gone wrong).
Edited by David Sikter