docbrown/app/controllers/internal/comments_controller.rb
Andy Zhao c42fd3461e
[deploy] Rename positive_reactions_count to public_reactions_count in logic (#7926)
* Rename positive_reactions_count to public_reactions_count

* Add positive reactions count back in so we can remove it

* Use public_category method for reactions

* Add positive_reactions_count in case any old caches rely on it

* Add positive_rxn_count to account for API endpoints

* Remove unused method

* One more spot...

* Add method back in because of caches

* Update specs to match new functionality

* Fix typo

* Remove unused methods
2020-05-26 12:36:28 -04:00

26 lines
831 B
Ruby

class Internal::CommentsController < Internal::ApplicationController
layout "internal"
def index
@comments = if params[:state]&.start_with?("toplast-")
Comment.
includes(:user).
includes(:commentable).
order("public_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