Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
b7d01c3
1
Parent(s):
38f3779
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
@@ -285,12 +285,9 @@ async def booking_trip(request: Request) -> Response:
|
|
285 |
elif raw_destination_city:
|
286 |
dest_code = origin_codes.get(raw_destination_city)
|
287 |
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)
|
288 |
-
print(route_ids)
|
289 |
try:
|
290 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
291 |
-
|
292 |
-
total = len(data)
|
293 |
-
if total > 0:
|
294 |
trips = []
|
295 |
routes_name = []
|
296 |
for trip in data:
|
|
|
285 |
elif raw_destination_city:
|
286 |
dest_code = origin_codes.get(raw_destination_city)
|
287 |
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)
|
|
|
288 |
try:
|
289 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
290 |
+
if len(data) > 0:
|
|
|
|
|
291 |
trips = []
|
292 |
routes_name = []
|
293 |
for trip in data:
|
app/dialogflow/services/dialog_service.py
CHANGED
@@ -73,16 +73,22 @@ class DialogService:
|
|
73 |
@staticmethod
|
74 |
async def search_trip(from_time: int, to_time: int, route_ids: list[int], ticket_count: int = 1):
|
75 |
try:
|
76 |
-
payload = {
|
77 |
"from_time": from_time,
|
78 |
"to_time": to_time,
|
79 |
"route_ids": route_ids,
|
80 |
"ticket_count": ticket_count,
|
81 |
"sort_by": ["price", "departure_time"]
|
|
|
82 |
}
|
83 |
|
|
|
84 |
response = await api.post("/search/trips", payload=payload)
|
85 |
-
|
|
|
|
|
|
|
|
|
86 |
return data
|
87 |
except Exception as e:
|
88 |
print(e)
|
|
|
73 |
@staticmethod
|
74 |
async def search_trip(from_time: int, to_time: int, route_ids: list[int], ticket_count: int = 1):
|
75 |
try:
|
76 |
+
payload = { k: v for k, v in {
|
77 |
"from_time": from_time,
|
78 |
"to_time": to_time,
|
79 |
"route_ids": route_ids,
|
80 |
"ticket_count": ticket_count,
|
81 |
"sort_by": ["price", "departure_time"]
|
82 |
+
}.items() if v is not None
|
83 |
}
|
84 |
|
85 |
+
data = []
|
86 |
response = await api.post("/search/trips", payload=payload)
|
87 |
+
if response.get("status") == 200:
|
88 |
+
if response.get("data"):
|
89 |
+
if response["data"].get("total") > 0:
|
90 |
+
data = response["data"]["items"]
|
91 |
+
print(data)
|
92 |
return data
|
93 |
except Exception as e:
|
94 |
print(e)
|