docbrown/app/models/concerns/reactable.rb
rhymes 33a11adca8
Various optimizations (#6249) [deploy]
* 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
2020-02-25 13:42:24 -05:00

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