Added seperate bracket/node logic
This commit is contained in:
+36
-56
@@ -1,15 +1,9 @@
|
||||
# backend/app/schemas.py
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from .constants import (
|
||||
BracketType,
|
||||
MatchSourceType,
|
||||
MatchStatus,
|
||||
TournamentTypes,
|
||||
WinnerSide,
|
||||
)
|
||||
from .constants import BracketType, MatchSourceType, MatchStatus, TournamentTypes
|
||||
|
||||
|
||||
class TeamSchema(BaseModel):
|
||||
@@ -38,53 +32,43 @@ class SetScore(BaseModel):
|
||||
|
||||
|
||||
class ScoreReport(BaseModel):
|
||||
id: str
|
||||
code: str | None = None
|
||||
sets: list[SetScore]
|
||||
|
||||
|
||||
class MatchOut(BaseModel):
|
||||
id: str
|
||||
number: int | None = None
|
||||
timestamp: datetime | None = None
|
||||
|
||||
court: str | None = Field(
|
||||
default=None, validation_alias="court_name", serialization_alias="court"
|
||||
)
|
||||
|
||||
bracket: BracketType
|
||||
round: int
|
||||
|
||||
p1: str | None = Field(
|
||||
default=None, validation_alias="p1_name", serialization_alias="p1"
|
||||
)
|
||||
p2: str | None = Field(
|
||||
default=None, validation_alias="p2_name", serialization_alias="p2"
|
||||
)
|
||||
|
||||
node_id: str
|
||||
status: MatchStatus
|
||||
timestamp: datetime | None = None
|
||||
court: CourtSchema | None = None
|
||||
p1_team: TeamSchema | None = None
|
||||
p2_team: TeamSchema | None = None
|
||||
winner_team_id: int | None = None
|
||||
|
||||
sets: list[SetScore] = []
|
||||
|
||||
previous_match_p1_id: str | None = Field(
|
||||
default=None, serialization_alias="source_p1"
|
||||
)
|
||||
previous_match_p2_id: str | None = Field(
|
||||
default=None, serialization_alias="source_p2"
|
||||
)
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class BracketNodeOut(BaseModel):
|
||||
id: str
|
||||
display_number: int
|
||||
bracket_type: BracketType
|
||||
round_number: int
|
||||
planned_start_time: datetime | None = None
|
||||
planned_court_id: int | None = None
|
||||
source_p1_node_id: str | None = None
|
||||
source_p2_node_id: str | None = None
|
||||
source_p1_type: MatchSourceType | None = None
|
||||
source_p2_type: MatchSourceType | None = None
|
||||
winner_next_node_id: str | None = None
|
||||
loser_next_node_id: str | None = None
|
||||
p1_team: TeamSchema | None = None
|
||||
p2_team: TeamSchema | None = None
|
||||
match: MatchOut | None = None
|
||||
|
||||
winner_next_match_id: str | None = Field(
|
||||
default=None, serialization_alias="next_win"
|
||||
)
|
||||
loser_next_match_id: str | None = Field(
|
||||
default=None, serialization_alias="next_loss"
|
||||
)
|
||||
|
||||
winner_side: WinnerSide = WinnerSide.NONE
|
||||
|
||||
model_config = ConfigDict(from_attributes=True, populate_by_name=True)
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class TournamentCreate(BaseModel):
|
||||
@@ -97,19 +81,7 @@ class TournamentCreate(BaseModel):
|
||||
courts: list[str]
|
||||
|
||||
|
||||
class TournamentOut(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
timestamp: datetime
|
||||
type: TournamentTypes
|
||||
team_count: int
|
||||
court_count: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class TournamentUpdate(BaseModel):
|
||||
|
||||
name: str | None = None
|
||||
code: str | None = None
|
||||
timestamp: datetime | None = None
|
||||
@@ -117,15 +89,23 @@ class TournamentUpdate(BaseModel):
|
||||
type: TournamentTypes | None = None
|
||||
|
||||
|
||||
class TournamentOut(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
timestamp: datetime
|
||||
type: TournamentTypes
|
||||
team_count: int
|
||||
court_count: int
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class TournamentDetail(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
code: str
|
||||
timestamp: datetime
|
||||
type: TournamentTypes
|
||||
teams: list[TeamSchema]
|
||||
courts: list[CourtSchema]
|
||||
matches: list[MatchOut]
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user