cubehouse / themeparks

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

.GetWaitTimes() never gives me updated data but SQLite DB shows new data. #185

Closed cbgrey closed 5 years ago

cbgrey commented 5 years ago

Park All I've tried.

Context

Describe the bug Running .GetWaitTimes() never gives me updated data. The SQLite DB has refreshed data but the call reports old/stale/cached data from somewhere. I've set and checked the cache timeouts to 60 seconds but it's the same result regardless.

Killing/restarting my node.js app will give me refreshed data.

The Park object appears to be staying alive. If I try to create multiple instances I get the expected error.

My simple code (just to echo data back to JSON): thePark.GetWaitTimes().then((waits) =>{ responseData['attractions'] = waits res.setHeader('Content-Type', 'application/json'); res.send(responseData) }).catch((error) => { console.error(error); })

I'm a new 5.x user so I may be doing something incorrectly but I've checked things multiple times.

Any guidance would be appreciated.

Output NA

cubehouse commented 5 years ago

I'm not seeing this behaviour, I've been running 5.x on a machine on and off for about 6 months or so, and appear to be getting ride updates fine.

The library does cache GetWaitTimes results in memory for 30 seconds, so maybe the 30 second cache isn't expiring? A lot of people directly call GetWaitTimes() from API calls, so the library tries to protect your local hard-drive (and the theme park's servers) from being hit too much by having a very short caching time in memory. This will likely change soon for the live Disney parks to flush the cache when a live update comes through, but the live update emitter won't be ready for a while as we had to push 5.x out early when the old API vanished.

Can you confirm if after 30 seconds the ride times do change correctly? Or if something else is occurring?

cbgrey commented 5 years ago

Thank you for the response. I'll try some things out.

Should I assume that "lastUpdate" will get updated even if there is no change in status or wait time?

{
meta: {
area: "Adventureland",
longitude: -81.583738382,
latitude: 28.4182264646,
},
id: "WaltDisneyWorldMagicKingdom_16124144",
name: "Walt Disney's Enchanted Tiki Room",
active: false,
waitTime: 0,
fastPass: false,
lastUpdate: "2019-06-18T01:10:07.077Z",
status: "Closed",
},

The current UTC time when I pulled that was 3:50a. Other attractions have varying "lastUpdate" times. Starting to wonder if I'm misunderstanding what that data element means.

cubehouse commented 5 years ago

lastUpdate is the last time the time was changed, so there may have been checks made since, but they might have returned the exact same value, so the time wouldn't have been updated.

Note that if you restart the process, the lastUpdate time will reset, as the ride object will be recreated in memory.

cbgrey commented 5 years ago

Ahhhhh. Then I think we can close this issue. I misunderstood and our implementation prior to v5 masked this as it generated a new Park object on each run. Thank you for taking the time to explain.

cubehouse commented 5 years ago

No worries! We could add a "lastChecked" timestamp or something I guess, if that is useful.