From 70f5d889290617bc5c3e47118be6dc0bc82c1744 Mon Sep 17 00:00:00 2001 From: Alexander J Sheehan Date: Wed, 8 May 2024 18:55:04 +0000 Subject: [PATCH] fix: updating group members with aggregate pagination num pages --- enterprise_access/apps/api/v1/views/subsidy_access_policy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/enterprise_access/apps/api/v1/views/subsidy_access_policy.py b/enterprise_access/apps/api/v1/views/subsidy_access_policy.py index 6efb9fb3..d36ed050 100755 --- a/enterprise_access/apps/api/v1/views/subsidy_access_policy.py +++ b/enterprise_access/apps/api/v1/views/subsidy_access_policy.py @@ -2,6 +2,7 @@ REST API views for the subsidy_access_policy app. """ import logging +import math import os from collections import defaultdict from contextlib import suppress @@ -123,6 +124,9 @@ def _update_pagination_params_for_group_aggregates( member_response['next'] = None member_response['previous'] = None + if sort_by_enrollment_count: + member_response['num_pages'] = math.ceil(num_member_results / GROUP_MEMBERS_WITH_AGGREGATES_DEFAULT_PAGE_SIZE) + def zip_group_members_data_with_enrollment_count(member_results, subsidy_learner_aggregate_dict): """Helper method to zip group member results with aggregate data from the subsidy service"""