mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-01 02:33:22 -04:00
* bump mypy * add pagination + refactor generic repo * add pagination test * remove all query object
28 lines
569 B
Python
28 lines
569 B
Python
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]
|