56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
"""
|
|
Pydantic schemas for matches.
|
|
|
|
This module defines request and response schemas for match-related operations.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
|
|
class MatchBase(BaseModel):
|
|
"""Base schema for match data."""
|
|
home_team: str = Field(..., min_length=1, max_length=255, description="Name of the home team")
|
|
away_team: str = Field(..., min_length=1, max_length=255, description="Name of the away team")
|
|
date: datetime = Field(..., description="Match date and time")
|
|
league: str = Field(..., min_length=1, max_length=255, description="League name")
|
|
status: str = Field(..., min_length=1, max_length=50, description="Match status")
|
|
|
|
|
|
class MatchCreate(MatchBase):
|
|
"""Schema for creating a new match."""
|
|
pass
|
|
|
|
|
|
class MatchUpdate(BaseModel):
|
|
"""Schema for updating a match."""
|
|
home_team: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
away_team: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
date: Optional[datetime] = None
|
|
league: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
status: Optional[str] = Field(None, min_length=1, max_length=50)
|
|
|
|
|
|
class MatchResponse(MatchBase):
|
|
"""Schema for match response."""
|
|
id: int = Field(..., description="Primary key")
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class MatchListResponse(BaseModel):
|
|
"""Schema for a list of matches."""
|
|
data: list[MatchResponse]
|
|
count: int = Field(..., description="Total number of matches")
|
|
meta: dict = Field(default_factory=dict, description="Additional metadata")
|
|
|
|
|
|
class MatchStatsResponse(BaseModel):
|
|
"""Schema for match statistics."""
|
|
total_matches: int = Field(..., description="Total number of matches")
|
|
matches_by_league: dict = Field(..., description="Breakdown by league")
|
|
matches_by_status: dict = Field(..., description="Breakdown by status")
|
|
upcoming_matches: int = Field(..., description="Number of upcoming matches")
|
|
completed_matches: int = Field(..., description="Number of completed matches")
|