From b2b23d81ed87cb01d3c30b387eee1251f75659e7 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Thu, 28 Nov 2024 10:55:14 +0000 Subject: [PATCH] Ensure ids are mapped to str instead of UUID --- api/cases/views/search/service.py | 10 +++++----- api/cases/views/search/views.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/cases/views/search/service.py b/api/cases/views/search/service.py index 8520633af6..475e711696 100644 --- a/api/cases/views/search/service.py +++ b/api/cases/views/search/service.py @@ -272,24 +272,24 @@ def populate_activity_updates(case_map): """ retrieve the last 2 activities per case for the provided list of cases """ - case_ids = list(case_map.keys()) + case_ids = list(str(pk) for pk in case_map.keys()) activities_qs = Audit.objects.get_latest_activities(case_ids, 2) # get users data for activities en bulk to reduce query count - user_ids = {activity.actor_object_id for activity in activities_qs} + user_ids = {str(activity.actor_object_id) for activity in activities_qs} users = BaseUser.objects.select_related("exporteruser", "govuser", "govuser__team").filter(id__in=user_ids) user_map = {str(user.id): user for user in users} for activity in activities_qs: case_id = None # get case id from either of the audit record fields - if activity.target_object_id in case_ids: + if str(activity.target_object_id) in case_ids: case_id = activity.target_object_id else: case_id = activity.action_object_object_id # prepopulate actor for AuditSerializer - actor = user_map[activity.actor_object_id] + actor = user_map[str(activity.actor_object_id)] activity_obj = serialize_case_activity(activity, actor) - case = case_map[case_id] + case = case_map[str(case_id)] if "activity_updates" in case: case["activity_updates"].append(activity_obj) else: diff --git a/api/cases/views/search/views.py b/api/cases/views/search/views.py index a14a9486be..3bfed83eff 100644 --- a/api/cases/views/search/views.py +++ b/api/cases/views/search/views.py @@ -55,7 +55,7 @@ def get(self, request, *args, **kwargs): case["advice"] = [] case["denials"] = [] case["goods"] = [] - case_map[case["id"]] = case + case_map[str(case["id"])] = case # Populate certain fields outside of the serializer for performance improvements service.populate_goods_flags(cases) service.populate_destinations_flags(cases)