OnlyBiggg commited on
Commit
413c742
·
1 Parent(s): d00bf5f
app/dialogflow/api/v1/dialogflow.py CHANGED
@@ -312,9 +312,7 @@ async def get_trip_list(request: Request) -> Response:
312
  ## Chưa tìm được
313
  trip_by_time_office = dialog_service.get_trip_by_time_and_office_id(data, time, origin_ids, dest_ids)
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
- print(trip_by_time_office)
317
-
318
  parameters = {
319
  "is_valid_trip": True,
320
  "trip": trip_by_time_office
@@ -388,7 +386,7 @@ async def get_trip_list(request: Request) -> Response:
388
  }
389
  )
390
 
391
-
392
  @router.post('/trip/route/list')
393
  async def booking_trip(request: Request) -> Response:
394
  body = await request.json()
@@ -580,6 +578,7 @@ async def select_time(request: Request) -> Response:
580
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
581
 
582
 
 
583
  @router.post('/trip/time-trip-list')
584
  async def time_trip(request: Request) -> Response:
585
  try:
@@ -654,6 +653,7 @@ async def time_trip(request: Request) -> Response:
654
  print(e)
655
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
656
 
 
657
  @router.post('/trip/check-time-select')
658
  async def is_valid_select_time(request: Request) -> Response:
659
  try:
@@ -750,7 +750,7 @@ 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
- text=["Vui lòng chọn ghế"]
754
  payload={
755
  "richContent": [
756
  [
 
312
  ## Chưa tìm được
313
  trip_by_time_office = dialog_service.get_trip_by_time_and_office_id(data, time, origin_ids, dest_ids)
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
 
386
  }
387
  )
388
 
389
+ # Không xài
390
  @router.post('/trip/route/list')
391
  async def booking_trip(request: Request) -> Response:
392
  body = await request.json()
 
578
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
579
 
580
 
581
+ # Không xài
582
  @router.post('/trip/time-trip-list')
583
  async def time_trip(request: Request) -> Response:
584
  try:
 
653
  print(e)
654
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
655
 
656
+ # Không xài
657
  @router.post('/trip/check-time-select')
658
  async def is_valid_select_time(request: Request) -> Response:
659
  try:
 
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
  "richContent": [
756
  [
app/dialogflow/services/dialog_service.py CHANGED
@@ -124,8 +124,6 @@ class DialogService:
124
  if time is None or origin_id is None or dest_id is None:
125
  return {}
126
 
127
- print(origin_id, dest_id)
128
- print(time)
129
  for trip in trips:
130
  if trip and trip["raw_departure_time"] == time and trip["route"]["origin_hub_office_id"] == origin_id and trip["route"]["dest_hub_office_id"] == dest_id:
131
  return trip
@@ -166,11 +164,13 @@ class DialogService:
166
  return []
167
 
168
  time_trips = [ trip["raw_departure_time"] for trip in trips]
 
169
  index = bisect_left(time_trips, time)
170
  start = max(0, index - 2)
171
  end = min(len(time_trips), index + 2)
172
-
173
- return trips[start:end]
 
174
 
175
 
176
 
 
124
  if time is None or origin_id is None or dest_id is None:
125
  return {}
126
 
 
 
127
  for trip in trips:
128
  if trip and trip["raw_departure_time"] == time and trip["route"]["origin_hub_office_id"] == origin_id and trip["route"]["dest_hub_office_id"] == dest_id:
129
  return trip
 
164
  return []
165
 
166
  time_trips = [ trip["raw_departure_time"] for trip in trips]
167
+ print(time_trips)
168
  index = bisect_left(time_trips, time)
169
  start = max(0, index - 2)
170
  end = min(len(time_trips), index + 2)
171
+ trips_result = trips[start:end]
172
+ print([ trip["raw_departure_time"] for trip in trips_result])
173
+ return trips_result
174
 
175
 
176