-
Notifications
You must be signed in to change notification settings - Fork 58
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
Get event locations directly from The Blue Alliance #190
Conversation
Get and cache event locations from directly from The Blue Alliance. Currently uses localStorage to store event data, which totals to about 0.5MB out of at least 5MB available to localStorage on major browsers.
Note that there are currently eighteen (18) duplicate locations in the events: Each CMP has seven events, five events at Saginaw Valley (MI CMP), three events at Paramount Fine Foods Center (ONT CMP), and two events at each of fourteen other locations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small things. Otherwise... damn son. Good work here. I hope you keep contributing, as I've graduated from my team and won't be maintaining this much. What year are you?
Prevent ReferenceError if query fails and cached data is not available for getTBAQuery (before it would give a reference error trying to get cached.data even if cached was undefined, so instead of getting a 'Error: [status code] received from TBA attempting to process query' it would result in a reference error. Also create an alert box with the error if no event information could be loaded at all so what is wrong is more obvious if it ever happens.
So for instance, in December 2019 events for 2020 will be shown on the map, since by the end of November all offseason events should be over and there should be event information for the next year available from TBA.
Thanks. I graduate in 2020, so this coming season is my last one. Also, I took care of the duplicate locations and event divisions the same way FIRSTMap-scraper does. I updated the CURRENT_YEAR to automatically roll over to the next year at the beginning of December since offseason events should be over by then and the events for the next year should be available from TBA. |
@GeeII Any objections? |
Other than the bit I wrote strangely, looks great! After this is deployed and passes some tests and a bit of use, I'll pull the event code from the scraper. |
Thanks for the suggestions. I will update the functions accordingly. |
Scatter in 4 directions instead of 3, and use a switch statement instead of chained if-else statements.
both look great! |
As I think on it, decoupling the team and event update cycles makes sense. Not having to worry about events, it may be worthwhile to merge the preceding year's teams (held in a cache file) with the current year's from roughly August/September to January/February in the scraper. |
I just noticed that |
getTBAQuery is asynchronous since it accesses TBA, so we have to open the url requested key (?key=eventCode) in the callback after all the events are added, instead of after the request function is called. If this is not done, the event markers probably won't exist when openURLKey is called, so an event marker specified in the url will not be opened, it will just be ignored.
@GeeII Ready to merge? |
Sure - I'll follow up with a teams.js update. Two "new" teams (#5 and #666), and new zip/postal codes for a bunch more which should improve things a bit. |
This allows event latitude and longitude data to be automatically pulled from The Blue Alliance and cached in localStorage (partial progress towards #185) instead of having to be updated manually through the FIRSTMap-scraper. Some of the code is based on FIRSTMap-scraper, and the map should behave exactly the same way it did before the change. Since there is no latitude and longitude data for teams available through TBA, team locations still have to be updated using the FIRSTMap-scraper.
Since all the event data is cached, I changed event marker
InfoWindow
s to use the cached data for all events instead of getting event info for each event individually from TBA.