From e3b77f642addc7392f4eccc037a1585032c910b1 Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Bayeki Date: Thu, 19 Dec 2024 08:44:24 -0800 Subject: [PATCH 1/2] fix: correct pagination to reflect filtered user count --- backend/lcfs/web/api/user/services.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/lcfs/web/api/user/services.py b/backend/lcfs/web/api/user/services.py index bd539f6bb..e20a3c7ff 100644 --- a/backend/lcfs/web/api/user/services.py +++ b/backend/lcfs/web/api/user/services.py @@ -125,16 +125,16 @@ async def get_all_users(self, pagination: PaginationRequestSchema) -> UsersSchem Get all users """ users, total_count = await self.repo.get_users_paginated(pagination=pagination) - if len(users) == 0: - raise DataNotFoundException("No users found") return UsersSchema( pagination=PaginationResponseSchema( total=total_count, page=pagination.page, size=pagination.size, - total_pages=math.ceil(total_count / pagination.size), + total_pages=( + math.ceil(total_count / pagination.size) if total_count > 0 else 0 + ), ), - users=users, + users=users if users else [], ) @service_handler From 45c8c733c8dc708448d184ac18d302762fbdd5c0 Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Bayeki Date: Thu, 19 Dec 2024 12:38:38 -0800 Subject: [PATCH 2/2] fix: remove unnecessary condition for get_users_paginated --- backend/lcfs/web/api/user/services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/lcfs/web/api/user/services.py b/backend/lcfs/web/api/user/services.py index e20a3c7ff..f6d21fa08 100644 --- a/backend/lcfs/web/api/user/services.py +++ b/backend/lcfs/web/api/user/services.py @@ -134,7 +134,7 @@ async def get_all_users(self, pagination: PaginationRequestSchema) -> UsersSchem math.ceil(total_count / pagination.size) if total_count > 0 else 0 ), ), - users=users if users else [], + users=users, ) @service_handler