mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:19:53 +01:00
Exclude pinned answers from pagination queries
This commit is contained in:
parent
33bd1ae9e4
commit
a37a498fb9
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue