Skip to content

Commit

Permalink
Faster caps update
Browse files Browse the repository at this point in the history
  • Loading branch information
greenape committed Apr 2, 2020
1 parent 9fd0a65 commit f9c6dae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flowauth/backend/flowauth/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ def edit_server_capabilities(server_id):
current_app.logger.debug(
"Editing capabilities for server", server_id=server_obj, new_permissions=json
)
caps = []
for cap, enabled in json.items():
try:
cap = ServerCapability.query.filter_by(
server_id=server_id, capability=cap
).one()
except NoResultFound:
cap = ServerCapability(server=server_obj, capability=cap)
cap = ServerCapability(server_id=server_id, capability=cap)
cap.enabled = enabled
db.session.add(cap)
caps.append(cap)
db.session.bulk_save_objects(caps)

for cap in to_remove:
db.session.delete(cap)
Expand Down

0 comments on commit f9c6dae

Please sign in to comment.