From 42c63547b1dd8ef2242106a2f8a69cb2c60164d5 Mon Sep 17 00:00:00 2001 From: tyrin Date: Mon, 26 May 2025 17:28:40 +0300 Subject: [PATCH] changed from using Max aggregatio to a separate query for the contamination status --- views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/views.py b/views.py index 5f99b17..6cf1b62 100644 --- a/views.py +++ b/views.py @@ -412,7 +412,6 @@ class UpperLimitView(APIView): .values("hpid") .annotate( counts=Sum("counts"), - contaminated=Max("contaminated"), ) .order_by("hpid") ) @@ -423,7 +422,14 @@ class UpperLimitView(APIView): # get lists of healpix indices and count values map_healpix_list = [d["hpid"] for d in map_pixels_list] map_counts_list = [d["counts"] for d in map_pixels_list] - map_contaminated_list = [d["contaminated"] for d in map_pixels_list] + + cont_dict = dict( + Pixel.objects.filter(hpid__in=map_healpix_list, survey__in=survey_numbers) + .values_list("hpid", "contaminated") + .distinct() + ) + + map_contaminated_list = [cont_dict[h] for h in map_healpix_list] # set map nside map_nside = 4096