X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/721f8e00b287974d6346e3c62bb8d0d599cc7db3..3d3b2b47964ec91ef1ab1946b7258a06665caced:/app/controllers/changeset_comments/feeds_controller.rb diff --git a/app/controllers/changeset_comments/feeds_controller.rb b/app/controllers/changeset_comments/feeds_controller.rb index fef48bb18..148873eea 100644 --- a/app/controllers/changeset_comments/feeds_controller.rb +++ b/app/controllers/changeset_comments/feeds_controller.rb @@ -1,5 +1,7 @@ module ChangesetComments class FeedsController < ApplicationController + include QueryMethods + before_action :authorize_web before_action :set_locale @@ -19,10 +21,13 @@ module ChangesetComments changeset = Changeset.find(changeset_id) # Return comments for this changeset only - @comments = changeset.comments.includes(:author, :changeset).reverse_order.limit(comments_limit) + @comments = changeset.comments.includes(:author, :changeset).reverse_order + @comments = query_limit(@comments) else # Return comments - @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC").limit(comments_limit).preload(:changeset) + @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC") + @comments = query_limit(@comments) + @comments = @comments.preload(:changeset) end # Render the result @@ -32,21 +37,5 @@ module ChangesetComments rescue OSM::APIBadUserInput head :bad_request end - - private - - ## - # Get the maximum number of comments to return - def comments_limit - if params[:limit] - if params[:limit].to_i.positive? && params[:limit].to_i <= 10000 - params[:limit].to_i - else - raise OSM::APIBadUserInput, "Comments limit must be between 1 and 10000" - end - else - 100 - end - end end end