Skip to content
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

Merged
merged 2 commits into from
Oct 31, 2020

Conversation

bvanzile
Copy link
Contributor

@bvanzile bvanzile commented Oct 29, 2020

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

  • Code changes have been tested against my own code, or there are no code changes

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

Edit by @favna: Closes #280

bvanzile and others added 2 commits October 31, 2020 14:01
getGamesAmerica will now always get all data and it has lost some
parameters in the process.

BREAKING CHANGE: getGamesAmerica no longer takes any parameters and
should always return all games.
@favna favna added Meta: BugFix PRs that fix bugs or issues. Priority: Critical Issues that must be fixed or PRs that must be finished and merged with maximum priority. SEM: Major PRs that contain breaking changes and should be released in the next major version. labels Oct 31, 2020
@favna favna merged commit 2ace2cc into lmmfranco:master Oct 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Meta: BugFix PRs that fix bugs or issues. Priority: Critical Issues that must be fixed or PRs that must be finished and merged with maximum priority. SEM: Major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API] Stopped getting new updates since last month from getGamesAmerica
2 participants