Spaces:
Sleeping
Sleeping
OnlyBiggg commited on
Commit ·
70eea09
1
Parent(s): 4348d23
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -308,18 +308,21 @@ async def get_trip_list(request: Request) -> Response:
|
|
| 308 |
try:
|
| 309 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
| 310 |
if len(data) > 0:
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
|
|
|
| 320 |
|
| 321 |
# Danh sách chuyến xe khớp với văn phòng đón hoặc văn phòng trả
|
| 322 |
-
data_by_office =
|
|
|
|
|
|
|
| 323 |
# Tìm 4 chuyến xe gần thời gian chỉ định nhất
|
| 324 |
trip_surrounding_time = dialog_service.get_4_surrounding_trip(data_by_office, time)
|
| 325 |
|
|
|
|
| 308 |
try:
|
| 309 |
data = await dialog_service.search_trip(from_time, to_time, route_ids, ticket_count)
|
| 310 |
if len(data) > 0:
|
| 311 |
+
if origin_office and dest_office:
|
| 312 |
+
trip_by_time_office = dialog_service.get_trip_by_time_and_office_id(data, time, origin_id, dest_id)
|
| 313 |
+
|
| 314 |
+
# Nếu có chuyến xe theo thời gian và văn phòng chỉ định
|
| 315 |
+
if trip_by_time_office:
|
| 316 |
+
parameters = {
|
| 317 |
+
"is_valid_trip": True,
|
| 318 |
+
"trip": trip_by_time_office
|
| 319 |
+
}
|
| 320 |
+
return DialogFlowResponseAPI(parameters=parameters)
|
| 321 |
|
| 322 |
# Danh sách chuyến xe khớp với văn phòng đón hoặc văn phòng trả
|
| 323 |
+
data_by_office = data
|
| 324 |
+
if origin_office or dest_office:
|
| 325 |
+
data_by_office = dialog_service.get_all_trip_by_office(data, origin_id, dest_id)
|
| 326 |
# Tìm 4 chuyến xe gần thời gian chỉ định nhất
|
| 327 |
trip_surrounding_time = dialog_service.get_4_surrounding_trip(data_by_office, time)
|
| 328 |
|
app/dialogflow/services/dialog_service.py
CHANGED
|
@@ -134,7 +134,7 @@ class DialogService:
|
|
| 134 |
@staticmethod
|
| 135 |
def get_all_trip_by_office(trips, origin_id: int = None, dest_id: int = None) -> list:
|
| 136 |
if origin_id is None and dest_id is None:
|
| 137 |
-
return
|
| 138 |
|
| 139 |
result = []
|
| 140 |
for trip in trips:
|
|
|
|
| 134 |
@staticmethod
|
| 135 |
def get_all_trip_by_office(trips, origin_id: int = None, dest_id: int = None) -> list:
|
| 136 |
if origin_id is None and dest_id is None:
|
| 137 |
+
return trips
|
| 138 |
|
| 139 |
result = []
|
| 140 |
for trip in trips:
|