Skip to content

Commit

Permalink
Filter orig_dep_date by including end_at and remove upper bound also …
Browse files Browse the repository at this point in the history
…for get_stop_times_between_stops
  • Loading branch information
gsarrco committed Dec 16, 2023
1 parent 03f262f commit 3553d4f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/base/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,20 @@ def get_stop_times_between_stops(self, dep_stops_ids, arr_stops_ids, line, start
.join(a_stop_times, and_(d_stop_times.number == a_stop_times.number,
d_stop_times.orig_dep_date == a_stop_times.orig_dep_date,
d_stop_times.source == a_stop_times.source))

start_day_minus_one = start_dt.date() - timedelta(days=1)
stmt = stmt.filter(d_stop_times.orig_dep_date >= start_day_minus_one)

if end_dt:
stmt = stmt.filter(d_stop_times.orig_dep_date <= end_dt.date())

stmt = stmt.filter(d_stop_times.orig_dep_date.between(day_minus_one, day),
d_stop_times.stop_id.in_(dep_stops_ids), a_stop_times.stop_id.in_(arr_stops_ids),
stmt = stmt.filter(d_stop_times.stop_id.in_(dep_stops_ids), a_stop_times.stop_id.in_(arr_stops_ids),
d_stop_times.sched_dep_dt < a_stop_times.sched_arr_dt)

if direction == 1:
stmt = stmt.filter(d_stop_times.sched_dep_dt >= start_dt)
if end_dt:
stmt = stmt.filter(d_stop_times.sched_dep_dt < end_dt)
stmt = stmt.filter(d_stop_times.sched_dep_dt <= end_dt)
else:
stmt = stmt.filter(d_stop_times.sched_dep_dt <= start_dt)
if end_dt:
Expand Down

0 comments on commit 3553d4f

Please sign in to comment.