Добавил id

This commit is contained in:
maksim 2024-06-09 16:42:05 +04:00
parent b390ed9c29
commit 84b1f81cc9
3 changed files with 5 additions and 3 deletions

View File

@ -185,6 +185,7 @@ def genetic_algorithm(start, end, graph, flights_data, type, departure_date, pop
for flight in flights_data:
if flight['departurePoint'] == path[i] and flight['destinationPoint'] == path[i + 1]:
path_data.append({
"id": flight['id'],
"departurePoint": flight['departurePoint'],
"destinationPoint": flight['destinationPoint']
})

View File

@ -11,7 +11,7 @@ router = APIRouter(
)
@router.post("/get/", response_model=List[TripOption])
@router.post("/get/", response_model=List[List[TripOption]])
async def get_flight(request: TripRequest):
graphTo, graphBack, start_point, end_point, flightsDataTo, flightsDataBack, departure_date, departure_date_return = load_graph_from_request(
request)
@ -28,7 +28,7 @@ async def get_flight(request: TripRequest):
for back_trip in resultFrom:
to_segments = [FlightSegment(**segment) for segment in to_trip["to"]]
back_segments = [FlightSegment(**segment) for segment in back_trip["back"]]
trip_options.append(TripOption(to=to_segments, back=back_segments))
trip_options.append([TripOption(to=to_segments, back=back_segments)])
return trip_options
@ -38,7 +38,7 @@ async def get_flight(request: TripRequest):
if not resultTo:
raise HTTPException(status_code=404, detail="No valid paths found")
trip_options = [TripOption(to=[FlightSegment(**segment) for segment in trip["to"]], back=[]) for trip in
trip_options = [[TripOption(to=[FlightSegment(**segment) for segment in trip["to"]], back=[])] for trip in
resultTo]
return trip_options

View File

@ -47,6 +47,7 @@ class Review(BaseModel):
name_ru: str
class FlightSegment(BaseModel):
id: int
departurePoint: str
destinationPoint: str