fix: avoid running final query when fetched_links == total_results #47
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.
What I am changing
This PR is a followup to #46 and seeks to fully fix #45.
PR #46 fixed fetching all of the links from ESA after they changed how pagination works, but didn't fully fix one piece that is essential to the Lambda function executing successfully. Specifically without this PR our link fetcher will still run a final query even after fetching all of the links that the API said are available.
To walk through an example ~> assume the API has a query offset limit of 100, and we page through in batches of 50,
To avoid this issue, this PR changes the link fetching behavior to exit once we've fetched all of the
totalResults
.How I did it
fetched_links == total_results
totalResults
(n=10)How you can test it
I added a unit test for this behavior that checks we do NOT run an additional query that has an
index
greater than the total result count.I also updated the link fetcher Lambda currently running and used this to get successful executions of our StepFunction ✅