You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For an API endpoint index action that has a simple filter action as:
def index
# Filter @agreements if ext_ref param is present
if params[:ext_ref].present?
@agreements = @agreements.where(ext_ref: params[:ext_ref])
end
end
This causes a change to the collection that Pagy is initialized with in: bullet_train-core/bullet_train-api/app/controllers/concerns/api/controllers/base.rb
def set_pagination_headers
return unless @pagy
if @pagy.has_more?
if (collection = instance_variable_get(collection_variable))
next_cursor = collection.last.id
link_header = response.headers["Link"]
link_value = "<#{modify_url_params(request.url, after: next_cursor)}>; rel=\"next\""
response.headers["Link"] = link_header ? "#{link_header}, #{link_value}" : link_value
response.headers["Pagination-Next"] = next_cursor
end
end
end
The the simple filter shown is run in between apply_pagination and set_pagination_header. The filtering can cause an empty collection which leads to an error in next_cursor = collection.last.id as collection is has no members.
The text was updated successfully, but these errors were encountered:
For an API endpoint index action that has a simple filter action as:
This causes a change to the collection that Pagy is initialized with in:
bullet_train-core/bullet_train-api/app/controllers/concerns/api/controllers/base.rb
where initialization takes place as:
Pagination headers are set later by:
The the simple filter shown is run in between apply_pagination and set_pagination_header. The filtering can cause an empty collection which leads to an error in
next_cursor = collection.last.id
as collection is has no members.The text was updated successfully, but these errors were encountered: