Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
456b94f
1
Parent(s):
df0b6b9
fix
Browse files- app/api/routes.py +0 -6
app/api/routes.py
CHANGED
|
@@ -13,7 +13,6 @@ router = APIRouter()
|
|
| 13 |
templates = Jinja2Templates(directory="app/templates")
|
| 14 |
|
| 15 |
def to_datetime_from_Dialogflow(time: dict):
|
| 16 |
-
print(time)
|
| 17 |
date_time = datetime(int(time["year"]), int(time["month"]), int(time["day"]))
|
| 18 |
return date_time
|
| 19 |
|
|
@@ -29,9 +28,7 @@ def process_dates_to_timestamp(from_time: datetime = None, to_time: datetime = N
|
|
| 29 |
return int(from_time.timestamp()) * 1000 , int(to_time.timestamp()) * 1000
|
| 30 |
def get_param_from_dialogflow(body: any):
|
| 31 |
session_info = body.get("sessionInfo", {})
|
| 32 |
-
print(session_info)
|
| 33 |
parameters = session_info.get("parameters", {}) if isinstance(session_info.get("parameters"), dict) else {}
|
| 34 |
-
print(parameters)
|
| 35 |
raw_date = parameters.get("date")
|
| 36 |
if raw_date is not None:
|
| 37 |
raw_date = to_datetime_from_Dialogflow(raw_date)
|
|
@@ -215,13 +212,11 @@ async def booking_trip(request: Request) -> Response:
|
|
| 215 |
"ticket_count": ticket_count,
|
| 216 |
"sort_by": ["price", "departure_time"]
|
| 217 |
}
|
| 218 |
-
print("I'm here")
|
| 219 |
try:
|
| 220 |
response = await api.post("/search/trips", payload=payload)
|
| 221 |
if response.get('status') == 200:
|
| 222 |
data = response["data"]["items"]
|
| 223 |
total = response["data"]["total"]
|
| 224 |
-
print(total)
|
| 225 |
if total > 0:
|
| 226 |
list_raw_departure_times = sorted(list(set([ trip["raw_departure_time"] for trip in data])))
|
| 227 |
schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
|
|
@@ -257,7 +252,6 @@ async def booking_trip(request: Request) -> Response:
|
|
| 257 |
"trip_list": trips,
|
| 258 |
"routes_name": routes_name
|
| 259 |
}
|
| 260 |
-
print(parameters)
|
| 261 |
return DialogFlowResponseAPI(text=text, payload=payload,parameters=parameters)
|
| 262 |
|
| 263 |
text = [f"Hệ thống không tìm thấy tuyến xe **{raw_departure_city}** - **{raw_destination_city}**.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
|
|
|
|
| 13 |
templates = Jinja2Templates(directory="app/templates")
|
| 14 |
|
| 15 |
def to_datetime_from_Dialogflow(time: dict):
|
|
|
|
| 16 |
date_time = datetime(int(time["year"]), int(time["month"]), int(time["day"]))
|
| 17 |
return date_time
|
| 18 |
|
|
|
|
| 28 |
return int(from_time.timestamp()) * 1000 , int(to_time.timestamp()) * 1000
|
| 29 |
def get_param_from_dialogflow(body: any):
|
| 30 |
session_info = body.get("sessionInfo", {})
|
|
|
|
| 31 |
parameters = session_info.get("parameters", {}) if isinstance(session_info.get("parameters"), dict) else {}
|
|
|
|
| 32 |
raw_date = parameters.get("date")
|
| 33 |
if raw_date is not None:
|
| 34 |
raw_date = to_datetime_from_Dialogflow(raw_date)
|
|
|
|
| 212 |
"ticket_count": ticket_count,
|
| 213 |
"sort_by": ["price", "departure_time"]
|
| 214 |
}
|
|
|
|
| 215 |
try:
|
| 216 |
response = await api.post("/search/trips", payload=payload)
|
| 217 |
if response.get('status') == 200:
|
| 218 |
data = response["data"]["items"]
|
| 219 |
total = response["data"]["total"]
|
|
|
|
| 220 |
if total > 0:
|
| 221 |
list_raw_departure_times = sorted(list(set([ trip["raw_departure_time"] for trip in data])))
|
| 222 |
schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
|
|
|
|
| 252 |
"trip_list": trips,
|
| 253 |
"routes_name": routes_name
|
| 254 |
}
|
|
|
|
| 255 |
return DialogFlowResponseAPI(text=text, payload=payload,parameters=parameters)
|
| 256 |
|
| 257 |
text = [f"Hệ thống không tìm thấy tuyến xe **{raw_departure_city}** - **{raw_destination_city}**.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
|