From a37a498fb9ce23d1690848c4216a65c000031f84 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Mon, 8 May 2023 20:29:27 +0200 Subject: [PATCH] Exclude pinned answers from pagination queries --- app/controllers/concerns/paginates_answers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/concerns/paginates_answers.rb b/app/controllers/concerns/paginates_answers.rb index 567eee25..2d5081c5 100644 --- a/app/controllers/concerns/paginates_answers.rb +++ b/app/controllers/concerns/paginates_answers.rb @@ -4,8 +4,8 @@ module PaginatesAnswers def paginate_answers @answers = yield(last_id: params[:last_id]) answer_ids = @answers.map(&:id) - answer_ids += @pinned_answers.pluck(:id) if @pinned_answers.present? @answers_last_id = answer_ids.min + answer_ids += @pinned_answers.pluck(:id) if @pinned_answers.present? @more_data_available = !yield(last_id: @answers_last_id, size: 1).count.zero? @subscribed_answer_ids = Subscription.where(user: current_user, answer_id: answer_ids).pluck(:answer_id) if user_signed_in? end