Fixup regression in 2eb89a835.

Fix regression in 2eb89a835 that broke the modqueue page because the
arguments to `paginated_search` changed and weren't updated here.

Also fix incorrect YARD documentation syntax.
This commit is contained in:
evazion
2021-09-29 06:26:49 -05:00
parent 627e8e1013
commit f9d25660b8
2 changed files with 10 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ class ModqueueController < ApplicationController
authorize :modqueue
@posts = Post.includes(:appeals, :disapprovals, :uploader, flags: [:creator]).in_modqueue.available_for_moderation(CurrentUser.user, hidden: search_params[:hidden])
@modqueue_posts = @posts.reselect(nil).reorder(nil).offset(nil).limit(nil)
@posts = @posts.paginated_search(params, order: "modqueue", count_pages: true, count: @modqueue_posts.to_a.size)
@posts = @posts.paginated_search(params, count_pages: true, count: @modqueue_posts.to_a.size, defaults: { order: "modqueue" })
@pending_post_count = @modqueue_posts.select(&:is_pending?).count
@flagged_post_count = @modqueue_posts.select(&:is_flagged?).count

View File

@@ -16,19 +16,20 @@ class ApplicationRecord < ActiveRecord::Base
# Perform a search using the model's `search` method, then paginate the results.
#
# params [Hash] The URL request params from the user
# page [Integer] The page number
# limit [Integer] The number of posts per page
# count_pages [Boolean] If true, show the exact number of pages of
# results. If false (the default), don't count the exact number of pages
# @param params [Hash] The URL request params from the user
# @param page [Integer] The page number
# @param limit [Integer] The number of posts per page
# @param count_pages [Boolean] If true, calculate the exact number of pages of
# results. If false (the default), don't calculate the exact number of pages
# of results; assume there are too many pages to count.
# defaults [Hash] The default params for the search
def paginated_search(params, page: params[:page], limit: params[:limit], count_pages: params[:search].present?, defaults: {})
# @param count [Integer] the precalculated number of search results, or nil to calculate it
# @param defaults [Hash] The default params for the search
def paginated_search(params, page: params[:page], limit: params[:limit], count_pages: params[:search].present?, count: nil, defaults: {})
search_params = params.fetch(:search, {}).permit!
search_params = defaults.merge(search_params).with_indifferent_access
max_limit = (params[:format] == "sitemap") ? 10_000 : 1_000
search(search_params).paginate(page, limit: limit, max_limit: max_limit, search_count: count_pages)
search(search_params).paginate(page, limit: limit, max_limit: max_limit, count: count, search_count: count_pages)
end
end
end