provisionning: delete superfluous roles in one query (#55043)
This commit is contained in:
parent
32ce076834
commit
5dc88fc9a7
|
@ -196,8 +196,7 @@ class NotificationProcessing:
|
|||
logger.error(u'cannot provision role "%s" (%s)', o['name'], o['uuid'])
|
||||
continue
|
||||
if full and action == 'provision':
|
||||
for role in Role.objects.exclude(uuid__in=uuids):
|
||||
role.delete()
|
||||
Role.objects.exclude(uuid__in=uuids).delete()
|
||||
elif action == 'deprovision':
|
||||
for role in Role.objects.filter(uuid__in=uuids):
|
||||
role.delete()
|
||||
|
|
|
@ -268,7 +268,7 @@ def test_hobo_notify_roles_db_queries(caplog, tenants):
|
|||
}
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
Command.process_notification(tenant, notification)
|
||||
assert len(ctx.captured_queries) == 45
|
||||
assert len(ctx.captured_queries) == 33
|
||||
assert Group.objects.count() == 1
|
||||
assert Role.objects.count() == 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue