1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

wip: pagination-repository (#1316)

* bump mypy

* add pagination + refactor generic repo

* add pagination test

* remove all query object
This commit is contained in:
Hayden 2022-05-30 10:30:54 -08:00 committed by GitHub
parent 00f144a622
commit 4c594a48dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 237 additions and 215 deletions

View file

@ -0,0 +1,27 @@
import enum
from typing import Generic, TypeVar
from pydantic import BaseModel
from pydantic.generics import GenericModel
DataT = TypeVar("DataT", bound=BaseModel)
class OrderDirection(str, enum.Enum):
asc = "asc"
desc = "desc"
class PaginationQuery(BaseModel):
page: int = 1
order_by: str = "created_at"
order_direction: OrderDirection = OrderDirection.desc
per_page: int = 50
class PaginationBase(GenericModel, Generic[DataT]):
page: int = 1
per_page: int = 10
total: int = 0
total_pages: int = 0
data: list[DataT]