This repository has been archived by the owner on Nov 6, 2021. It is now read-only.
fix(api): updated getgamesamerica algolia request to retrieve all games #281
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed, in #280.
To be straight forward, I'm no master of Node and this is the first time I've been exposed to a lot of the configurations in this repo. I put together this commit to fix the getGamesAmerica Algolia request that wasn't returning all games.
I wasn't able to incorporate the parameters that this function made use of before (options, offset, games[]). Since my goal was the most efficient way to retrieve all games, I wasn't sure of the best way to include options such as limit and offset. Filtering based on GameUS[] seems doable but to be honest I wasn't really sure how the previous iteration worked alongside the other parameters so I left it out for now.
getGamesAmerica now simply makes one url call to Algolia with 8 requests to retrieve all of the games. The 8 calls are fairly static for the moment, but two of them will need to be adjusted by the time ~180 more Switch games rated Everyone are added to the Algolia response (so not for a while probably).
How it works:
These 8 calls make use of 2 indexNames that return all games sorted by ascending title and then by descending title. Each request returns up to 1000 games (the max allowed). Everyone, Everyone10+, and Teen all have >1000 and <2000 total hits, so combining the indexNames gets the first 1000 games starting from the beginning and 1000 games starting from the end, then the overlapping duplicates are purged. Mature has only ~460 games so only one call is needed and one more call for Availability: Coming Soon is made with only 125 results since this call probably contains all games with no rating.
I also commented out the getGamesAmerica test case that checked for allowing parameters since I removed that functionality in this iteration.
The getGamesAmerica call in this pr returns 4632 games for me.
yarn lint and yarn test both passed.
It's a simple solution so let me know how you guys want to proceed.
Status
Semantic versioning classification:
Edit by @favna: Closes #280