cubehouse / themeparks

Unofficial API for accessing ride wait times and schedules for Disneyland, Disney World, Universal Studios, and many more parks
MIT License
544 stars 126 forks source link

Ride Schedules Bug #42

Closed dunkmann00 closed 7 years ago

dunkmann00 commented 7 years ago

As of 4.0, when calling GetWaitTimes() after having called GetOpeningTimes() the ride schedule data will always be missing. This will also happen if the ttl of wait times is shorter than the ttl of opening times.

I believe this is happening because ride schedules are stored with the ride cache data. So if you call GetOpeningTimes() and there are no rides to attach ride schedules to, the data is just discarded. But if a call is then made to GetWaitTimes(), the ride info is downloaded, and GetOpeningTimes() is called again. However, it won't download all the opening times again, it just pulls them from the "openingtimes" cache. But the cache does not have any ride opening times, so ride schedules will remain missing.

It is a similar situation when the ride wait times cache is cleared before the opening times cache is cleared (i.e. cacheWaitTimesLength = 60 and cacheOpeningTimesLength = 300). When the new ride info is downloaded it will try to get the new schedule times as well. But since the opening times are still in the cache it won't download it again. And since only the park opening times are in the cache, not the ride opening times, the schedule data on the ride will be missing.

I hope this is clear enough. I encountered this problem while trying to get ride info for the Disney parks in case that helps. I would be glad to try to further explain this problem if it is necessary.

I also tried to see if there was a simple way of correcting this and was unable to come up with anything.

Thanks for looking into it!

cubehouse commented 7 years ago

Hi, thanks for your very clear and investigated bug report!

I will investigate and see if I can devise a fix as soon as I get a moment. I'm not happy with how the rides are cached at the moment, so I might have to patch this in an ugly way before I really re-think how to cache data better.

cubehouse commented 7 years ago

I've pushed 4.0.3, so now we pull out the ride schedule data and store it separately, then when getting wait times, we check this local store and grab times if they exist.

To make sure the store is filled, we request an opening hours update before getting wait times.

That should cover both cases of calling wait times before opening hours, and visa-versa. See commit above to see what I think will fix the issue.

Please let me know if this fixes the issue.

dunkmann00 commented 7 years ago

This is great! Seems to be working fine now. Thanks!