docbrown/app/controllers/internal/comments_controller.rb
Jacob Herrington 40bc7ecedd
Remove unnecessary eager loading (#6063)
Bullet doesn't seem to like this, and it makes sense because we don't
want to load ALL reactions, just some of them.

Co-authored-by: nspinazz89 <nspinazz89@gmail.com>

Co-authored-by: Nick S <nspinazz89@gmail.com>
2020-02-17 09:39:30 -05:00

26 lines
833 B
Ruby

class Internal::CommentsController < Internal::ApplicationController
layout "internal"
def index
@comments = if params[:state]&.start_with?("toplast-")
Comment.
includes(:user).
includes(:commentable).
order("positive_reactions_count DESC").
where("created_at > ?", params[:state].split("-").last.to_i.days.ago).
page(params[:page] || 1).per(50)
else
Comment.
includes(:user).
includes(:commentable).
order("created_at DESC").
page(params[:page] || 1).per(50)
end
end
private
def authorize_admin
authorize Comment, :access?, policy_class: InternalPolicy
end
end