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:
parent
00f144a622
commit
4c594a48dc
21 changed files with 237 additions and 215 deletions
27
mealie/schema/response/pagination.py
Normal file
27
mealie/schema/response/pagination.py
Normal 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]
|
Loading…
Add table
Add a link
Reference in a new issue