Добавил id
This commit is contained in:
@@ -185,6 +185,7 @@ def genetic_algorithm(start, end, graph, flights_data, type, departure_date, pop
|
|||||||
for flight in flights_data:
|
for flight in flights_data:
|
||||||
if flight['departurePoint'] == path[i] and flight['destinationPoint'] == path[i + 1]:
|
if flight['departurePoint'] == path[i] and flight['destinationPoint'] == path[i + 1]:
|
||||||
path_data.append({
|
path_data.append({
|
||||||
|
"id": flight['id'],
|
||||||
"departurePoint": flight['departurePoint'],
|
"departurePoint": flight['departurePoint'],
|
||||||
"destinationPoint": flight['destinationPoint']
|
"destinationPoint": flight['destinationPoint']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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):
|
async def get_flight(request: TripRequest):
|
||||||
graphTo, graphBack, start_point, end_point, flightsDataTo, flightsDataBack, departure_date, departure_date_return = load_graph_from_request(
|
graphTo, graphBack, start_point, end_point, flightsDataTo, flightsDataBack, departure_date, departure_date_return = load_graph_from_request(
|
||||||
request)
|
request)
|
||||||
@@ -28,7 +28,7 @@ async def get_flight(request: TripRequest):
|
|||||||
for back_trip in resultFrom:
|
for back_trip in resultFrom:
|
||||||
to_segments = [FlightSegment(**segment) for segment in to_trip["to"]]
|
to_segments = [FlightSegment(**segment) for segment in to_trip["to"]]
|
||||||
back_segments = [FlightSegment(**segment) for segment in back_trip["back"]]
|
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
|
return trip_options
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ async def get_flight(request: TripRequest):
|
|||||||
if not resultTo:
|
if not resultTo:
|
||||||
raise HTTPException(status_code=404, detail="No valid paths found")
|
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]
|
resultTo]
|
||||||
|
|
||||||
return trip_options
|
return trip_options
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Review(BaseModel):
|
|||||||
name_ru: str
|
name_ru: str
|
||||||
|
|
||||||
class FlightSegment(BaseModel):
|
class FlightSegment(BaseModel):
|
||||||
|
id: int
|
||||||
departurePoint: str
|
departurePoint: str
|
||||||
destinationPoint: str
|
destinationPoint: str
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user