1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Fixed "mass retrieval" of properties for items list of service pools

This commit is contained in:
Adolfo Gómez García 2024-02-01 02:36:33 +01:00
parent d4ae8f589f
commit 70ccbc3591
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23

View File

@ -124,13 +124,13 @@ class AssignedService(DetailHandler):
if not item:
# First, fetch all properties for all assigned services on this pool
# We can cache them, because they are going to be readed anyway...
properties: dict[str, typing.Any] = {
k: v
for k, v in models.Properties.objects.filter(
owner_type='userservice',
owner_id__in=parent.assigned_user_services().values_list('uuid', flat=True),
).values_list('key', 'value')
}
properties: dict[str, typing.Any] = collections.defaultdict(dict)
for id, key, value in models.Properties.objects.filter(
owner_type='userservice',
owner_id__in=parent.assigned_user_services().values_list('uuid', flat=True),
).values_list('owner_id', 'key', 'value'):
properties[id][key] = value
return [
AssignedService.item_as_dict(k, properties.get(k.uuid, {}))
for k in parent.assigned_user_services()