feat: Add combined track functionality with repository and service layers
- Introduced CombinedTrackModel, CombinedTrackCreate, and CombinedTrackRepository for managing combined tracks. - Implemented logic to create combined tracks based on existing tracks between two stations. - Added methods to check for existing combined tracks and retrieve constituent track IDs. - Enhanced TrackModel and TrackRepository to support OSM ID and track updates. - Created migration scripts for adding combined tracks table and OSM ID to tracks. - Updated services and API endpoints to handle combined track operations. - Added tests for combined track creation, repository methods, and API interactions.
This commit is contained in:
@@ -8,11 +8,14 @@ from .auth import (
|
||||
UserPublic,
|
||||
)
|
||||
from .base import (
|
||||
CombinedTrackCreate,
|
||||
CombinedTrackModel,
|
||||
StationCreate,
|
||||
StationModel,
|
||||
StationUpdate,
|
||||
TrackCreate,
|
||||
TrackModel,
|
||||
TrackUpdate,
|
||||
TrainCreate,
|
||||
TrainModel,
|
||||
TrainScheduleCreate,
|
||||
@@ -33,9 +36,12 @@ __all__ = [
|
||||
"StationUpdate",
|
||||
"TrackCreate",
|
||||
"TrackModel",
|
||||
"TrackUpdate",
|
||||
"TrainScheduleCreate",
|
||||
"TrainCreate",
|
||||
"TrainModel",
|
||||
"UserCreate",
|
||||
"to_camel",
|
||||
"CombinedTrackCreate",
|
||||
"CombinedTrackModel",
|
||||
]
|
||||
|
||||
@@ -51,13 +51,24 @@ class StationModel(IdentifiedModel[str]):
|
||||
class TrackModel(IdentifiedModel[str]):
|
||||
start_station_id: str
|
||||
end_station_id: str
|
||||
length_meters: float
|
||||
max_speed_kph: float
|
||||
length_meters: float | None = None
|
||||
max_speed_kph: float | None = None
|
||||
status: str | None = None
|
||||
is_bidirectional: bool = True
|
||||
coordinates: list[tuple[float, float]] = Field(default_factory=list)
|
||||
|
||||
|
||||
class CombinedTrackModel(IdentifiedModel[str]):
|
||||
start_station_id: str
|
||||
end_station_id: str
|
||||
length_meters: float | None = None
|
||||
max_speed_kph: int | None = None
|
||||
status: str | None = None
|
||||
is_bidirectional: bool = True
|
||||
coordinates: list[tuple[float, float]] = Field(default_factory=list)
|
||||
constituent_track_ids: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class TrainModel(IdentifiedModel[str]):
|
||||
designation: str
|
||||
capacity: int
|
||||
@@ -89,6 +100,31 @@ class TrackCreate(CamelModel):
|
||||
start_station_id: str
|
||||
end_station_id: str
|
||||
coordinates: Sequence[tuple[float, float]]
|
||||
osm_id: str | None = None
|
||||
name: str | None = None
|
||||
length_meters: float | None = None
|
||||
max_speed_kph: int | None = None
|
||||
is_bidirectional: bool = True
|
||||
status: str = "planned"
|
||||
|
||||
|
||||
class TrackUpdate(CamelModel):
|
||||
start_station_id: str | None = None
|
||||
end_station_id: str | None = None
|
||||
coordinates: Sequence[tuple[float, float]] | None = None
|
||||
osm_id: str | None = None
|
||||
name: str | None = None
|
||||
length_meters: float | None = None
|
||||
max_speed_kph: int | None = None
|
||||
is_bidirectional: bool | None = None
|
||||
status: str | None = None
|
||||
|
||||
|
||||
class CombinedTrackCreate(CamelModel):
|
||||
start_station_id: str
|
||||
end_station_id: str
|
||||
coordinates: Sequence[tuple[float, float]]
|
||||
constituent_track_ids: list[str]
|
||||
name: str | None = None
|
||||
length_meters: float | None = None
|
||||
max_speed_kph: int | None = None
|
||||
|
||||
Reference in New Issue
Block a user