Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No data updates after 24h #5

Open
hallonstedt opened this issue Nov 10, 2022 · 5 comments
Open

No data updates after 24h #5

hallonstedt opened this issue Nov 10, 2022 · 5 comments

Comments

@hallonstedt
Copy link
Contributor

hallonstedt commented Nov 10, 2022

I have gotten TimeTableApi.py up and running after applying pull-request #4 but now another issue has appeared.

The received data doesn't update when the process has been left running for an extended period of time. I do get a response when accessing the end-point but it is outdated and does not take the current time into account so I receive the same departure times regardless when I access the server.

If I restart the process I immediately get updated information. My guess is that some data is only loaded on process start and then never refreshed. When I restart the process, the following message appears which may be a hint;

2022-11-09 10:01:09,298 - root - INFO - GTFS archive is older than 1 day
2022-11-09 10:01:09,298 - root - INFO - Updating GTFS archive

Is this something you could take a look at. I am, of course, happy to helt testing but I am not a programmer so I don't think I will sort this on my own.

Truth be told, I just want to get real-time data from my home bus-stop and was hoping an existing API would do the trick but I do not get real-time data from ResRobot 2.1 using, for example, this query:
https://api.resrobot.se/v2.1/departureBoard?id=740000944&duration=20&passlist=1&format=xml&accessId=[my-key]
According to the documentation, Skånetrafiken provides real-time values like rTime/rDate but they do not appear in the response XML. Is there any other API and/or query I could use?

@Bertware
Copy link
Member

According to the documentation, Skånetrafiken provides real-time values like rTime/rDate but they do not appear in the response XML. Is there any other API and/or query I could use?

This is an error in the documentation. Skånes realtime data used to be included, but Resrobot is currently quite limited in how realtime data can be integrated. We are looking at possible solutions to include more realtime data in Resrobot, but there is not time estimate on when this could be done.

The reason the application stops working after a while is because it only loads the gtfs file at startup, so after 24h it starts complaining. I'll see if I can add a background job to update the GTFS file once a day, that way it could keep running.

@hallonstedt
Copy link
Contributor Author

Thank you, that would be ideal. For now, I'll write an ugly batch-script that kills and re-starts the process nightly.

@hallonstedt
Copy link
Contributor Author

It seems my problem statement above was incorrect.

The problem with the application is that upon restart, it loads 2 hours worth of departures from the selected bus stop and after that it never updates that window. This means that if I reload the page during the 2 hour window, I will get updated information about the buses that are in motion but it will not add to the list. After two hours, all buses are at their destination and the page remains static until I restart the process and get a new 2 hour window.

This means that in order to provide value, I now have to restart the TimeTableApi.py application every hour and adjust the outcome to reflect current time + 1 hour. It works, but it is not pretty!

There may be an issue with the gtfs files not being updated as well but we can only know once above behavior is resolved.

@hallonstedt
Copy link
Contributor Author

hallonstedt commented Sep 11, 2024

After a year, I have finally found myself with a bit of time on my hands and have managed to identify a few simple fixes that I think will add value. I added them to PR #11 for you to review.

@hallonstedt
Copy link
Contributor Author

The only remaining issue after above PR is the filtering and selection of stop times when the time window spans across midnight. Currently, no departures are provided past midnight before the current time also is past midnight.

I have solved this issue by adding each of the functions involved in GtfsTimeTable.py to a Jupyter notebook and creating loads of verbose logging. Unfortunately, the end code is more or less rewritten so I am struggling to make meaningful code-commits.

I therefore decided to exclude this update in the PR above (#11) and will submit it for your review once the above PR is merged (I haven't managed to figure out how to submit a PR to the baseline of a pending PR)

Additionally, now that I got everything working perfectly, I got a all excited and added a bit of extra functionality such as a config-file with lots of configuration options, improved logging and updated documentation. This will follow if above PR's are merged. Brace for impact 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants