From e3b77f642addc7392f4eccc037a1585032c910b1 Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Bayeki Date: Thu, 19 Dec 2024 08:44:24 -0800 Subject: [PATCH] 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