Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
7282551
1
Parent(s):
413bfe0
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -301,9 +301,7 @@ async def get_trip_list(request: Request) -> Response:
|
|
| 301 |
dest_ids = await dialog_service.find_id_office_by_name_office(dest_office)
|
| 302 |
elif raw_destination_city:
|
| 303 |
dest_id, dest_code = get_origin_id_and_code(raw_destination_city)
|
| 304 |
-
route_ids = await dialog_service.search_all_route_ids(origin_code=origin_code, from_id=origin_id, orign_ids=origin_ids, dest_code=dest_code, to_id=dest_id, dest_ids=dest_ids)
|
| 305 |
-
print(route_ids)
|
| 306 |
-
|
| 307 |
|
| 308 |
try:
|
| 309 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
|
@@ -499,9 +497,10 @@ async def is_valid_select_trip(request: Request) -> Response:
|
|
| 499 |
|
| 500 |
if raw_input:
|
| 501 |
raw_input = raw_input.strip()
|
| 502 |
-
for item in
|
| 503 |
if item["route"] == raw_input:
|
| 504 |
-
|
|
|
|
| 505 |
parameters = {
|
| 506 |
"is_valid_trip": True,
|
| 507 |
"trip": trip
|
|
|
|
| 301 |
dest_ids = await dialog_service.find_id_office_by_name_office(dest_office)
|
| 302 |
elif raw_destination_city:
|
| 303 |
dest_id, dest_code = get_origin_id_and_code(raw_destination_city)
|
| 304 |
+
route_ids = await dialog_service.search_all_route_ids(origin_code=origin_code, from_id=origin_id, orign_ids=origin_ids, dest_code=dest_code, to_id=dest_id, dest_ids=dest_ids)
|
|
|
|
|
|
|
| 305 |
|
| 306 |
try:
|
| 307 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
|
|
|
| 497 |
|
| 498 |
if raw_input:
|
| 499 |
raw_input = raw_input.strip()
|
| 500 |
+
for item in trip_select:
|
| 501 |
if item["route"] == raw_input:
|
| 502 |
+
id = int(item["trip_id"])
|
| 503 |
+
trip = dialog_service.get_trip_by_id(trips, id)
|
| 504 |
parameters = {
|
| 505 |
"is_valid_trip": True,
|
| 506 |
"trip": trip
|
app/dialogflow/services/dialog_service.py
CHANGED
|
@@ -179,6 +179,12 @@ class DialogService:
|
|
| 179 |
if trip_id == item["id"]:
|
| 180 |
return item
|
| 181 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
@staticmethod
|
| 184 |
async def stops(route_id: int, way_id: int):
|
|
|
|
| 179 |
if trip_id == item["id"]:
|
| 180 |
return item
|
| 181 |
return None
|
| 182 |
+
@staticmethod
|
| 183 |
+
def get_trip_by_id(trip_id: int, trips: list):
|
| 184 |
+
for trip in trips:
|
| 185 |
+
if trip and trip["id"] == trip_id:
|
| 186 |
+
return trip
|
| 187 |
+
return {}
|
| 188 |
|
| 189 |
@staticmethod
|
| 190 |
async def stops(route_id: int, way_id: int):
|