Update tell position logic and add new endpoint

Refactored tell position logic to use `segment` and `puck_in_segment` fields, replacing the previous single `tell_position` field. Introduced a new `/set-tell-positions` endpoint for setting tell positions based on these changes and removed the deprecated endpoint handling the old logic. Enhanced validation and streamlined handling of related logistics and puck events.
This commit is contained in:
GotthardG
2024-12-19 13:21:37 +01:00
parent deeee02211
commit 14eaca81c6
2 changed files with 138 additions and 49 deletions

View File

@ -338,8 +338,27 @@ class SlotSchema(BaseModel):
class SetTellPosition(BaseModel):
tell_position: str = Field(
...,
pattern="^[A-F][1-5]$|^null$|^None$", # Use 'pattern' instead of 'regex'
description="Valid values are A1-A5, B1-B5, ..., F1-F5, or null.",
puckname: str # The puck name is required.
segment: Optional[str] = Field(
None,
pattern="^[A-F]$", # Valid segments are A, B, C, D, E, F
description="Segment must be one of A, B, C, D, E, or F."
"Can be null for no tell_position.",
)
puck_in_segment: Optional[int] = Field(
None,
ge=1,
le=5,
description="Puck in segment must be between 1 and 5."
"Can be null for no tell_position.",
)
@property
def tell_position(self) -> Optional[str]:
"""
Combines `segment` and `puck_in_segment` to generate the `tell_position`.
If either value is `None`, returns `None` to indicate no `tell_position`.
"""
if self.segment and self.puck_in_segment:
return f"{self.segment}{self.puck_in_segment}"
return None