Skip to content
Snippets Groups Projects

order opening hours so the next timetable is the good one

1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
+ 6
2
@@ -19,8 +19,12 @@ def get_waiting_time(place: str, db: Session):
""" Get the last estimated waiting time for the given place """
current_date = datetime.now(tz=pytz.timezone("Europe/Paris"))
weekday, current_time = current_date.weekday(), current_date.time()
opening_hours = db.query(models.OpeningHours.open_time, models.OpeningHours.close_time).filter(
models.OpeningHours.place == place, models.OpeningHours.day == weekday).all()
opening_hours = db.query(
models.OpeningHours.open_time,
models.OpeningHours.close_time).filter(
models.OpeningHours.place == place,
models.OpeningHours.day == weekday).order_by(
models.OpeningHours.open_time).all()
for time_slot in opening_hours:
if current_time < time_slot.open_time:
return schemas.WaitingTime(next_timetable=time_slot.open_time.strftime('%Hh%M'))
Loading