Skip to content
Snippets Groups Projects
Commit 97e89f9f authored by hkethi002's avatar hkethi002 Committed by GitHub
Browse files

Merge pull request #791 from scitran/db-double-tags

Database upgrade double tagging fix
parents c6466f4f 12161e00
No related branches found
No related tags found
No related merge requests found
......@@ -962,23 +962,26 @@ def upgrade_to_26_closure(job):
return True
# This logic WILL NOT WORK in parallel mode
gear_name = gear['gear']['name']
# Update doc
result = config.db.jobs.update_one({'_id': job['_id']}, {'$push': {'tags': gear_name }})
# Checks if the specific gear tag already exists for the job
if gear_name in job['tags']:
return True
result = config.db.jobs.update_one({'_id': job['_id']}, {'$addToSet': {'tags': gear_name }})
if result.modified_count == 1:
return True
else:
return 'Parallel failed: update doc ' + str(job['_id']) + ' resulted modified ' + str(result.modified_count)
def upgrade_to_26():
"""
scitran/core #734
Add job tags back to the job document, and use a faster cursor-walking update method
"""
cursor = config.db.jobs.find({})
process_cursor(cursor, upgrade_to_26_closure)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment