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.
Closes #9283 (cont'd)
Technical
offset
to zero as well. This doesn't do much in the context of this PR since the output of the validation function should never go below 1, but it's there in case the validation function ever changes, or anything along those lines. I thought about adding an offset validation check further upstream but ultimately I think it should be the consumer function's job to make sure it's passing correct information to the DB interface.Testing
I repeated my tests from #9323 and #9361. I inserted 25 following and 26 follower records, and then deleted them to test the empty list case.
Screenshot
I redid all of my tests just in case.
Following - 25 total, only one possible page:
The output is identical with an invalid page query param (http://localhost:8080/people/openlibrary/following?page=100, http://localhost:8080/people/openlibrary/following?page=-1, http://localhost:8080/people/openlibrary/following?page=0, http://localhost:8080/people/openlibrary/following?page=aaaaa) and with a valid one (http://localhost:8080/people/openlibrary/following?page=1).
Followers - 26 total, 2 possible pages:
No page param specified in the URL:
The output is identical with an invalid page query param (http://localhost:8080/people/openlibrary/followers?page=-1, http://localhost:8080/people/openlibrary/followers?page=0, http://localhost:8080/people/openlibrary/followers?page=qqqqqqqqq) and with a valid one (http://localhost:8080/people/openlibrary/followers?page=1).
Page 2, selected by pagination UI:
The output is identical with an invalid page query param (http://localhost:8080/people/openlibrary/followers?page=4932930580).
No followers:
The output is identical with an invalid page query param (http://localhost:8080/people/openlibrary/followers?page=100, http://localhost:8080/people/openlibrary/followers?page=-1, http://localhost:8080/people/openlibrary/followers?page=0, http://localhost:8080/people/openlibrary/followers?page=wdasfresfmkdmb) and with a valid one (http://localhost:8080/people/openlibrary/followers?page=1).
Results are the same incognito.
Stakeholders
@mekarpeles
Attribution Disclaimer: By proposing this pull request, I affirm to have made a best-effort and exercised my discretion to make sure relevant sections of this code which substantially leverage code suggestions, code generation, or code snippets from sources (e.g. Stack Overflow, GitHub) have been annotated with basic attribution so reviewers & contributors may have confidence and access to the correct context to evaluate and use this code.