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

Get event locations directly from The Blue Alliance #190

Merged
merged 7 commits into from
Jun 28, 2019

Conversation

EthShaw
Copy link
Member

@EthShaw EthShaw commented Jun 25, 2019

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 InfoWindows to use the cached data for all events instead of getting event info for each event individually from TBA.

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.
@GeeII
Copy link
Member

GeeII commented Jun 26, 2019

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.

Copy link
Member

@ErikBoesen ErikBoesen left a 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?

scripts.js Outdated Show resolved Hide resolved
scripts.js Outdated Show resolved Hide resolved
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.
@EthShaw
Copy link
Member Author

EthShaw commented Jun 26, 2019

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.

@ErikBoesen
Copy link
Member

@GeeII Any objections?

@GeeII
Copy link
Member

GeeII commented Jun 27, 2019

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.

@EthShaw
Copy link
Member Author

EthShaw commented Jun 27, 2019

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.
@GeeII
Copy link
Member

GeeII commented Jun 27, 2019

both look great!

@GeeII
Copy link
Member

GeeII commented Jun 27, 2019

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.

@EthShaw
Copy link
Member Author

EthShaw commented Jun 27, 2019

I just noticed that openURLKey has to be called at the end of the callback function where all the events are added instead of after getTBAQuery is called since the event markers do not exist until the callback function passed to getTBAQuery is run. Otherwise, the event key in the URL parameter is ignored as though the event does not exist, so the event isn't selected on page load.

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.
@ErikBoesen
Copy link
Member

@GeeII Ready to merge?

@GeeII
Copy link
Member

GeeII commented Jun 27, 2019

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.

@ErikBoesen ErikBoesen merged commit 20f8737 into FIRSTMap:master Jun 28, 2019
@EthShaw EthShaw deleted the tba-retrieve branch June 28, 2019 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants