Last active
November 10, 2019 16:02
-
-
Save fitnr/5889d55c9d0bb5ada9c79cd51a54de74 to your computer and use it in GitHub Desktop.
Example of inserting missing service_id into a GTFS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO gtfs.calendar (feed_index, service_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, start_date, end_date) | |
SELECT a.feed_index, a.service_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, start_date, end_date | |
FROM ( | |
SELECT feed_index, service_id | |
FROM gtfs.trips a | |
LEFT JOIN gtfs.calendar b using (feed_index, service_id) | |
WHERE COALESCE(b.monday, b.friday) IS NULL | |
GROUP BY feed_index, service_id | |
) a | |
INNER JOIN gtfs.calendar b ON a.feed_index = b.feed_index AND ( | |
replace(a.service_id, '-BM', '-SDon-BM') = b.service_id OR | |
a.service_id || '-SDon' = b.service_id | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment