Skip to content

Commit

Permalink
frequencies: respect spec when enumerating frequencies_row 🐛💥
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Nov 2, 2024
1 parent 1ee678e commit 1ffda35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/frequencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ SET frequencies_row = t.frequencies_row
FROM (
SELECT
-- order by all columns so that we don't implicitly depend on the file's order
(row_number() OVER (PARTITION BY trip_id, exact_times ORDER BY start_time, end_time, headway_secs))::integer AS frequencies_row,
(row_number() OVER (PARTITION BY trip_id, start_time ORDER BY end_time, headway_secs, exact_times))::integer AS frequencies_row,
trip_id, start_time
FROM "${opt.schema}".frequencies
) AS t
-- self-join
-- frequencies' primary is just (trip_id, start_time)
-- see also https://github.com/google/transit/issues/514
WHERE frequencies.trip_id = t.trip_id
AND frequencies.exact_times = t.exact_times;
AND frequencies.start_time = t.start_time;
CREATE INDEX ON "${opt.schema}".frequencies (trip_id);
CREATE INDEX ON "${opt.schema}".frequencies (exact_times);
Expand Down

0 comments on commit 1ffda35

Please sign in to comment.