File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,9 +136,16 @@ def get_workergroups():
136136@requires_auth
137137def post_workergroups ():
138138 workergroups = json .loads (request .form ["workergroups" ])
139+
140+ # Remove workergroups which hasn't be sent but were present previously (supposed deleted)
141+ workergroup_list_json = list (workergroups .keys ())
142+ workergroup_list_mongo = [document ["_id" ] for document in connections .mongodb_jobs .mrq_workergroups .find ()]
143+ workergroup_to_delete_list = list (set (workergroup_list_mongo ) - set (workergroup_list_json ))
144+ for workergroup_id in workergroup_to_delete_list :
145+ connections .mongodb_jobs .mrq_workergroups .delete_one ({"_id" : workergroup_id })
146+
139147 for k , v in workergroups .iteritems ():
140148 connections .mongodb_jobs .mrq_workergroups .update_one ({"_id" : k }, {"$set" : v }, upsert = True )
141-
142149 return jsonify ({"status" : "ok" })
143150
144151
You can’t perform that action at this time.
0 commit comments