always call jsonapi_page_size method on pagination enabled requests#40
Merged
stas merged 4 commits intostas:masterfrom Feb 16, 2021
Merged
Conversation
pass the per_page_param to the jsonapi_page_size method
Contributor
Author
|
@stas let me know if the implementation works for you, so i can add some docs and tests |
Owner
|
@fluxsaas this looks good. Two suggestions:
Thank youuuu!!! 🙇 |
…ion in jsonapi_page_size
Contributor
Author
|
@stas great, i think it makes sense to pass in the We would also avoid passing a string OR nil value to the method. def jsonapi_page_size(pagination_params)
per_page = pagination_params[:size].to_f.to_i
return self.class
.const_get(:JSONAPI_PAGE_SIZE)
.to_i if per_page < 1
per_page
endsee files for the updated version |
Owner
|
@fluxsaas sounds good. Are we ready to merge this? 🙃 |
Contributor
Author
|
looks good from my side, i improved the Readme to reflect the changes. |
Owner
|
Sweet! I'll prepare the release in a bit! Thank you @fluxsaas 🙇 |
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.
What is the current behavior?
related to issue #37
if you set the params
page[size]in the query,jsonapi_page_sizeis not called andpage[size]is used to determine the page size of the paginated response.What is the new behavior?
always call the module method
jsonapi_page_sizeand pass the value of the query parampage[size]to the method to define the page size of the paginated response. Fallback toJSONAPI_PAGE_SIZEifpage[size]is lower than 1 or not present in the query string at all.Checklist
Please make sure the following requirements are complete:
features)