docbrown/app/controllers/admin/privileged_reactions_controller.rb
Jeremy Friesen 95969eb973
Caching sum privileged reaction scores (#15299)
* Caching sum privileged reaction scores

This relates to work on improving the feed.  Namely that in the current
proposal in PR #15240 I'm not accounting for how privileged users have
given feedback on an article.

With this change, I will now have a cached value on the articles table
that can be a proxy for how the privileged users have reacted.

In addition there's a small refactor that moves a constant to the
correct scoping object.

Dependent on #15283.

* Fixing method name to `exists?`

Prior to this commit, I was using `exist?` which doesn't work for
ActiveRecord::Relation objects.
2021-11-08 12:50:08 -05:00

14 lines
356 B
Ruby

module Admin
class PrivilegedReactionsController < Admin::ApplicationController
layout "admin"
def index
@q = Reaction
.includes(:user, :reactable)
.privileged_category
.order(created_at: :desc)
.ransack(params[:q])
@privileged_reactions = @q.result.page(params[:page] || 1).per(25)
end
end
end