Skip to content

Commit

Permalink
Get normal headsign instead cluster name headsign for efficiency in G…
Browse files Browse the repository at this point in the history
…TFS sql
  • Loading branch information
gsarrco committed Oct 5, 2023
1 parent fafc641 commit a81a7b0
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions MuoVErsi/sources/GTFS/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_sqlite_stop_times(self, stop: Station, line, start_time, day,
select_elements = """
dep.departure_time as dep_time,
r.route_short_name as line,
hs_cluster_name as headsign,
dep.stop_headsign as headsign,
t.trip_id as trip_id,
dep.stop_sequence as stop_sequence,
s.stop_name as dep_stop_name,
Expand All @@ -250,18 +250,6 @@ def get_sqlite_stop_times(self, stop: Station, line, start_time, day,
query = f"""
SELECT {select_elements}
FROM stop_times dep
INNER JOIN (SELECT trip_id, stops_clusters.name as hs_cluster_name
FROM stop_times st
INNER JOIN stops ON st.stop_id = stops.stop_id
INNER JOIN stops_stops_clusters ON stops.stop_id = stops_stops_clusters.stop_id
INNER JOIN stops_clusters ON stops_stops_clusters.stop_cluster_id = stops_clusters.id
WHERE st.stop_sequence = (
SELECT MAX(stop_times.stop_sequence)
FROM stop_times
WHERE stop_times.trip_id = st.trip_id
)
)
hs ON dep.trip_id = hs.trip_id
INNER JOIN (SELECT trip_id, departure_time as orig_dep_time, stop_id as orig_stop_id
FROM stop_times
WHERE stop_sequence = 1
Expand Down Expand Up @@ -305,7 +293,8 @@ def get_sqlite_stop_times(self, stop: Station, line, start_time, day,
dep_dt = datetime.combine(day, dep_time)
orig_dep_time = time(result[9], result[10])
orig_dep_date = day if orig_dep_time <= dep_time else day - timedelta(days=1)
stop_time = TripStopTime(stop, result[8], dep_dt, result[4], 0, location, result[2], result[3], result[1], dep_dt, orig_dep_date, result[2])
headsign = result[2] if result[2] else ''
stop_time = TripStopTime(stop, result[8], dep_dt, result[4], 0, location, headsign, result[3], result[1], dep_dt, orig_dep_date, result[2])
stop_times.append(stop_time)

return stop_times
Expand Down

0 comments on commit a81a7b0

Please sign in to comment.