Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
73750fe
1
Parent(s):
35ddb1d
fix: seat trip
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
@@ -750,20 +750,23 @@ async def seats_trip(request: Request) -> Response:
|
|
750 |
seats = await dialog_service.seats_trip(route_id, trip_id, departure_date, departure_time, kind)
|
751 |
seats_empty = [ seat for seat in seats if seat["bookStatus"] == 0 ]
|
752 |
seats_empty.sort(key=lambda x: x["chair"])
|
753 |
-
print(seats_empty)
|
754 |
text=["Quý khách vui lòng chọn ghế"]
|
755 |
-
payload={
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
|
|
|
|
|
|
764 |
]
|
765 |
-
|
766 |
-
|
|
|
767 |
parameters = {
|
768 |
"seat_list": seats
|
769 |
}
|
|
|
750 |
seats = await dialog_service.seats_trip(route_id, trip_id, departure_date, departure_time, kind)
|
751 |
seats_empty = [ seat for seat in seats if seat["bookStatus"] == 0 ]
|
752 |
seats_empty.sort(key=lambda x: x["chair"])
|
|
|
753 |
text=["Quý khách vui lòng chọn ghế"]
|
754 |
+
payload = {}
|
755 |
+
if seats_empty:
|
756 |
+
payload={
|
757 |
+
"richContent": [
|
758 |
+
[
|
759 |
+
{
|
760 |
+
"type": "chips",
|
761 |
+
"options": [
|
762 |
+
{"text": seat["chair"]} for seat in (seats_empty)
|
763 |
+
]
|
764 |
+
}
|
765 |
+
]
|
766 |
]
|
767 |
+
}
|
768 |
+
else:
|
769 |
+
text = ["Không còn ghế trống. Quý khách vui lòng lựa chọn chuyến khác"]
|
770 |
parameters = {
|
771 |
"seat_list": seats
|
772 |
}
|
app/dialogflow/services/dialog_service.py
CHANGED
@@ -88,7 +88,7 @@ class DialogService:
|
|
88 |
if params is None:
|
89 |
return []
|
90 |
response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/seats/{route_id}/{trip_id}" , params=params)
|
91 |
-
if response.get("data"):
|
92 |
return []
|
93 |
seats = response["data"]
|
94 |
return seats
|
|
|
88 |
if params is None:
|
89 |
return []
|
90 |
response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/seats/{route_id}/{trip_id}" , params=params)
|
91 |
+
if not response.get("data"):
|
92 |
return []
|
93 |
seats = response["data"]
|
94 |
return seats
|
common/external/external_api.py
CHANGED
@@ -26,7 +26,6 @@ class API():
|
|
26 |
|
27 |
except httpx.HTTPStatusError as http_err:
|
28 |
## RETRY FOR 403 ERROR
|
29 |
-
print('Lỗi: ',http_err.response.status_code)
|
30 |
if http_err.response.status_code == 403 or http_err.response.status_code == 401:
|
31 |
headers.pop("Authorization", None)
|
32 |
|
|
|
26 |
|
27 |
except httpx.HTTPStatusError as http_err:
|
28 |
## RETRY FOR 403 ERROR
|
|
|
29 |
if http_err.response.status_code == 403 or http_err.response.status_code == 401:
|
30 |
headers.pop("Authorization", None)
|
31 |
|