diff --git a/backend/common/pagination.py b/backend/common/pagination.py index e356c050..4800f19a 100644 --- a/backend/common/pagination.py +++ b/backend/common/pagination.py @@ -54,19 +54,19 @@ class _CustomPage(_PageDetails, AbstractPage[T], Generic[T]): @classmethod def create( cls, - items: Sequence[SchemaT], + items: list, total: int, params: _CustomPageParams, ) -> _CustomPage[T]: page = params.page size = params.size total_pages = ceil(total / params.size) - links = create_links(**{ - 'first': {'page': 1, 'size': f'{size}'}, - 'last': {'page': f'{ceil(total / params.size)}', 'size': f'{size}'} if total > 0 else 1, - 'next': {'page': f'{page + 1}', 'size': f'{size}'} if (page + 1) <= total_pages else None, - 'prev': {'page': f'{page - 1}', 'size': f'{size}'} if (page - 1) >= 1 else None, - }).model_dump() + links = create_links( + first={'page': 1, 'size': size}, + last={'page': f'{ceil(total / params.size)}', 'size': size} if total > 0 else {'page': 1, 'size': size}, + next={'page': f'{page + 1}', 'size': size} if (page + 1) <= total_pages else None, + prev={'page': f'{page - 1}', 'size': size} if (page - 1) >= 1 else None, + ).model_dump() return cls( items=items, @@ -74,7 +74,7 @@ def create( page=params.page, size=params.size, total_pages=total_pages, - links=links, + links=links, # type: ignore )