Add event counting methods and generic pagination schema

Introduce methods to count user, public, and upcoming events to enhance CRUD functionality for events. Additionally, add a `PaginatedResponse` schema to simplify and standardize paginated API responses. These updates support improved data querying and response handling.
This commit is contained in:
2025-03-09 10:56:22 +01:00
parent 5c73f2720e
commit fe2bcbd6e7
2 changed files with 84 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
from typing import Generic, List, TypeVar
from pydantic import BaseModel
T = TypeVar('T')
class PaginatedResponse(BaseModel, Generic[T]):
"""
Generic schema for paginated responses.
Attributes:
total (int): Total number of items
items (List[T]): List of items in the current page
page (int): Current page number
size (int): Number of items per page
"""
total: int
items: List[T]
page: int
size: int
class Config:
from_attributes = True