Skip to content

Commit

Permalink
Refactor name PaginationParams
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Dec 20, 2024
1 parent 4a5b6a7 commit 5620389
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/routers/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from ..datasources.db.database import get_database_session
from ..datasources.db.models import Contract
from ..services.contract import ContractService
from ..services.pagination import GenericPagination, PaginatedResponse, PaginationParams
from ..services.pagination import (
GenericPagination,
PaginatedResponse,
PaginationQueryParams,
)
from .models import ContractsPublic

router = APIRouter(
Expand All @@ -22,7 +26,7 @@
async def list_contracts(
request: Request,
address: str,
pagination_params: PaginationParams = Depends(),
pagination_params: PaginationQueryParams = Depends(),
chain_ids: Annotated[list[int] | None, Query()] = None,
session: AsyncSession = Depends(get_database_session),
) -> PaginatedResponse[Contract]:
Expand Down
3 changes: 2 additions & 1 deletion app/services/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PaginatedResponse(BaseModel, Generic[T]):
results: list[T]


class PaginationParams(BaseModel):
class PaginationQueryParams(BaseModel):
limit: int | None = Query(None, ge=1)
offset: int | None = Query(0, ge=0)

Expand Down Expand Up @@ -85,6 +85,7 @@ async def get_count(self, session: AsyncSession, query) -> int:
def serialize(self, url: URL, results: list[Any], count: int) -> PaginatedResponse:
"""
Get serialized page of results.
:param url:
:param results:
:param count:
Expand Down

0 comments on commit 5620389

Please sign in to comment.