Skip to content

Commit

Permalink
removed fixing up of multiple identical tags
Browse files Browse the repository at this point in the history
  • Loading branch information
hkethi002 committed May 22, 2017
1 parent a7030a0 commit 7df77b3
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions bin/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,29 +963,12 @@ def upgrade_to_26_closure(job):
# This logic WILL NOT WORK in parallel mode

gear_name = gear['gear']['name']
gear_name_tag_count = 0

# Checks if the specific gear tag already exists for the job
# for tag in job['tags']:
# if tag == gear_name:
# # logging.info("Gear name tag already exists")
# return True


# Update doc

# Check for multiples
for tag in job['tags']:
if tag == gear_name:
gear_name_tag_count = gear_name_tag_count + 1
if gear_name_tag_count > 1:
logging.info("job "+ job + " has multiple gear name tags")
config.db.jobs.update_one({'_id': job['_id']}, {'$pull': {'tags': gear_name}})
result = config.db.jobs.update_one({'_id': job['_id']}, {'$set': {'tags': gear_name}})
elif gear_name_tag_count == 1:
if gear_name in job['tags']:
return True
else:
result = config.db.jobs.update_one({'_id': job['_id']}, {'$addToSet': {'tags': gear_name }})
result = config.db.jobs.update_one({'_id': job['_id']}, {'$addToSet': {'tags': gear_name }})

if result.modified_count == 1:
return True
Expand Down

0 comments on commit 7df77b3

Please sign in to comment.