Removing a user from a permission (e.g. via UI or from add_user_to_group.py) leaves an empty project role record like:
{ "_id" : ObjectId("5d4da66907ae31602eafd9b7"), "project_id" : ObjectId("5d4da66907ae31602eafd9b1"), "user_id" : ObjectId("538f723ff697c62562ed9a43"), "name" : null, "roles" : [ ] }
As far as I can tell that doesn't serve any purpose and should be removed. Worth testing a bit more to confirm though.
Then script up removal of those records and change ProjectRole
remove
code.
Semi-related add_user_to_group.py shouldn't merely flush_all(), it should flush individual records or expunge
records after its done with them, so that doesn't accumulate a giant list of objects in its ming session.
on branch db/8364
general cleanup is not really necessary, but can be done with
db.project_role.remove({user_id:{$ne:null}, roles:[]});
Fixes are merged.