Skip to content

Commit 095e2b1

Browse files
committed
Fix pagination
1 parent 4b927c8 commit 095e2b1

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

pyazo_api/domain/images/actions/get_images.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ class GetImagesAction:
1010
def __init__(self, image_repository: Annotated[ImageRepository, Depends()]):
1111
self.image_repository: ImageRepository = image_repository
1212

13-
async def __call__(self, owner: UserGet, pagination: PaginationRequest) -> PaginatedResults:
14-
return await self.image_repository.get_paginated_images_by_owner_id(owner.id, pagination)
13+
async def __call__(
14+
self, owner: UserGet, pagination: PaginationRequest
15+
) -> PaginatedResults:
16+
return await self.image_repository.get_paginated_images_by_owner_id(
17+
owner.id, pagination
18+
)

pyazo_api/util/auth.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ async def get_user(
3838
algorithms=[settings.jwt_algorithm],
3939
)
4040
except PyJWTError as e:
41-
print("AAAAAAAAAAAAAAAAAA", str(e))
4241
return None
4342

4443
try:
4544
data = TokenData.model_validate(payload)
4645
except ValidationError as e:
47-
print("BBBBBBBBBBBBBBBBBB", str(e))
4846
return None
4947

5048
return await user_repository.get_by_username(data.sub)

pyazo_api/util/pagination.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def offset(self) -> int:
2020
return self.page * self.limit
2121

2222

23-
class PaginatedResults(BaseModel):
24-
results: list[BaseModel]
23+
class PaginatedResults[T](BaseModel):
24+
results: list[T]
2525
count: int
2626
next_page: int
2727

28-
def get_results(self) -> Iterator[BaseModel]:
28+
def get_results(self) -> Iterator[T]:
2929
for result in self.results:
3030
yield result
3131

0 commit comments

Comments
 (0)