Skip to content

Commit

Permalink
sensor/gtfs: add sanity check, origin earlier than destination (#2265)
Browse files Browse the repository at this point in the history
Previously experienced issues on routes where services operate in both
directions. The query picked up not just paths where service goes
from Origin ->  Destination, but trips going Destination -> Origin,
and shown bogus results.

Ensure that this doesn't happen by requiring the origin station's
stop_sequence value to be lower than the destination station.
  • Loading branch information
imrehg authored and balloob committed Jun 12, 2016
1 parent da5b508 commit 31c1b7f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/sensor/gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def get_next_departure(sched, start_station_id, end_station_id):
AND time(origin_stop_time.departure_time) > time(:now_str)
AND start_station.stop_id = :origin_station_id
AND end_station.stop_id = :end_station_id
AND origin_stop_time.stop_sequence < destination_stop_time.stop_sequence
ORDER BY origin_stop_time.departure_time LIMIT 1;
""".format(day_name=day_name))
result = sched.engine.execute(sql_query, now_str=now_str,
Expand Down

0 comments on commit 31c1b7f

Please sign in to comment.