Skip to content
Snippets Groups Projects
Commit 258c572e authored by Aymeric Chaumont's avatar Aymeric Chaumont
Browse files

Merge branch 'fix_next_timetable' into 'main'

order opening hours so the next timetable is the good one

See merge request !46
parents 33ab7391 c3f00d1a
Branches
No related tags found
1 merge request!46order opening hours so the next timetable is the good one
Pipeline #44392 failed
...@@ -19,8 +19,12 @@ def get_waiting_time(place: str, db: Session): ...@@ -19,8 +19,12 @@ def get_waiting_time(place: str, db: Session):
""" Get the last estimated waiting time for the given place """ """ Get the last estimated waiting time for the given place """
current_date = datetime.now(tz=pytz.timezone("Europe/Paris")) current_date = datetime.now(tz=pytz.timezone("Europe/Paris"))
weekday, current_time = current_date.weekday(), current_date.time() weekday, current_time = current_date.weekday(), current_date.time()
opening_hours = db.query(models.OpeningHours.open_time, models.OpeningHours.close_time).filter( opening_hours = db.query(
models.OpeningHours.place == place, models.OpeningHours.day == weekday).all() 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: for time_slot in opening_hours:
if current_time < time_slot.open_time: if current_time < time_slot.open_time:
return schemas.WaitingTime(next_timetable=time_slot.open_time.strftime('%Hh%M')) return schemas.WaitingTime(next_timetable=time_slot.open_time.strftime('%Hh%M'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment