* Pluck over map * Explain why map makes sense there * Refactor reactions controller a bit and iterate only once * Use group by instead of N counting queries * More positive * Simplify BufferedArticlesController * Less queries for MailchimpBot * Use Rails instead of SQL * Build comment_ids only when needed
11 lines
263 B
Ruby
11 lines
263 B
Ruby
module Reactable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_many :reactions, as: :reactable, inverse_of: :reactable, dependent: :destroy
|
|
end
|
|
|
|
def sync_reactions_count
|
|
update_column(:positive_reactions_count, reactions.positive.size)
|
|
end
|
|
end
|