From 70ccbc359175ea1c28e6c77c9b7dbc33eaef8280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 1 Feb 2024 02:36:33 +0100 Subject: [PATCH] Fixed "mass retrieval" of properties for items list of service pools --- server/src/uds/REST/methods/user_services.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/uds/REST/methods/user_services.py b/server/src/uds/REST/methods/user_services.py index ad77aec68..7f7d3433c 100644 --- a/server/src/uds/REST/methods/user_services.py +++ b/server/src/uds/REST/methods/user_services.py @@ -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()