Skip to content

Commit

Permalink
fix: correct pagination to reflect filtered user count
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-valiollahi committed Dec 19, 2024
1 parent 09dd16a commit e3b77f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/lcfs/web/api/user/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e3b77f6

Please sign in to comment.