trynmaps / metrics-mvp

Prototype of public transit data visualization system
https://muni.opentransit.city
MIT License
30 stars 34 forks source link

Update routes for specific dates #638

Open Brian-Lee opened 4 years ago

Brian-Lee commented 4 years ago

Fixes #626

Proposed changes

Get the feed from transitfeeds (https://api.transitfeeds.com/v1/getFeedVersions?key={your-key}3&feed=sfmta%2F60&page=1&limit=10&err=1&warn=1) Use get the last 10 (changeable) previous versions of the GTFS files. Use those files in save_routes.py to save routes to subfolders in /backend/data. Subfolders and files have date suffixs.

These older versions of route JSON files can then be used for historical queries. ...

Screenshot

folder_screenshot

... Tests: Command: python3 save_routes.py --agency trimet (saves route_v3a_trimet_2020-MM-DD) where MM-DD is today's date) ... Command: python3 save_routes.py --agency trimet --date 2000-02-02 (gives error "an active GTFS for this date was not found " as we don't have a GTFS file qualifying for 2002-02-02) ... Command: python3 save_routes.py --agency muni --date 2020-02-22 (saves routes_v3a_muni-2020-02-18 as gtfs-muni-2020-02-18.zip is the recentmost qualifying GTFS) image

...

...

Brian-Lee commented 4 years ago

I made a bunch of changes and I think I addressed everything mentioned. However, I am not sure that the Nextbus files are working correctly. Shouldn't they also be in date versioned folders?

Brian-Lee commented 4 years ago

Hey @Brian-Lee I'm really sorry for the delay in reviewing this, I'll be faster in the follow-ups. Getting closer, I've added some comments. Request a review from me in the PR whenever you're ready. Thanks!

No worries! Thanks for helping me!

Brian-Lee commented 4 years ago

Just wondering, could you, in the PR description, write out a list of what you did to test your PR? A section on Tests is part of the PR template (not completely sure), so that's missing.

It should look something like this:

Tests: Command: python3 save_routes.py --agency trimet ... Command: python3 save_routes.py --agency trimet --date 2000-02-02 (should give error as we don't have a GTFS from then) ... Command: python3 save_routes.py --agency trimet --date 2020-02-22 ... (saves route_v3a_trimet_2020-02-22...)

Great suggestion. I put in a few hypothetical test cases. The actual results depend on the date and the contents of your directory.

hathix commented 4 years ago

Eddy, does this look good at this point?