-
Notifications
You must be signed in to change notification settings - Fork 66
Closed
Description
Hello!
regarding the new jsonapi_page_size implementation, i would like to suggest to always call the method jsonapi_page_size even if the params page[size] is passed to the request:
jsonapi.rb/lib/jsonapi/pagination.rb
Lines 97 to 104 in 3a685a7
| def jsonapi_pagination_params | |
| pagination = params[:page].try(:slice, :number, :size) || {} | |
| per_page = pagination[:size].to_f.to_i | |
| per_page = jsonapi_page_size if per_page < 1 | |
| num = [1, pagination[:number].to_f.to_i].max | |
| [(num - 1) * per_page, per_page, num] | |
| end |
a use case could be to implement a logic to set/overwrite the max size of a response:
def jsonapi_page_size
pagination = params[:page].try(:size) || {}
per_page = pagination[:size] || 50
per_page = 50 if per_page.to_f.to_i > 50
return per_page
endbest ✌️
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels