Adding last page limit and include config to set the max results per page#1
Merged
Conversation
Khrol
reviewed
Jan 19, 2023
Khrol
reviewed
Jan 19, 2023
Khrol
reviewed
Jan 19, 2023
Khrol
reviewed
Jan 19, 2023
Khrol
reviewed
Jan 19, 2023
Khrol
requested changes
Jan 19, 2023
Khrol
left a comment
There was a problem hiding this comment.
While your code works fine, you somehow try to complicate things.
Author
|
Pagination error test:
|
joaopamaral
commented
Jan 19, 2023
| # Don't raise a NotFoundException | ||
| return None | ||
|
|
||
| if error_code == 422 and PAGINATION_EXCEED_MSG in response_json.get('message', ''): |
Author
There was a problem hiding this comment.
The error 422 can be raised for other reasons, that is why we are comparing the message to check if it's related to pagination.
joaopamaral
commented
Jan 19, 2023
| timer.tags[metrics.Tag.http_status_code] = resp.status_code | ||
| rate_throttling(resp, self.max_sleep_seconds, self.min_remain_rate_limit) | ||
| if resp.status_code == 404: | ||
| if resp.status_code == 404 or resp.status_code == 422: |
Author
There was a problem hiding this comment.
No need to check the response message again because if the error code is 422 and it's not a pagination error, the raise_for_error method will raise an exception.
joaopamaral
commented
Jan 19, 2023
| Call rest API and return the response in case of status code 200. | ||
| """ | ||
| with metrics.http_request_timer(source) as timer: | ||
| with metrics.http_request_timer(url) as timer: |
Author
There was a problem hiding this comment.
This is already expecting the endpoint, it makes it easier to identify the request in logs.
Khrol
approved these changes
Jan 20, 2023
Khrol
left a comment
There was a problem hiding this comment.
Way better now and more clear what's going on.
Thank you, LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of change
Last page check
This new check verifies if the request reached the last page and avoids the following pagination error (GitHub API limits the result to 40k records):
Max records per page configurable
The other change includes an option to define the max results per page and set by default the max results allowed by the Github API to reduce the number of requests.
Manual QA steps
Risks
Rollback steps