Module: Likeable

Extended by:
ActiveSupport::Concern
Included in:
Model
Defined in:
app/models/concerns/likeable.rb

Instance Method Summary collapse

Instance Method Details

#update_like_count! ⇒ Object



4
5
6
7
8
# File 'app/models/concerns/likeable.rb', line 4

def update_like_count!
  count = list_items.includes(:list).where("list.special": :liked).count +
    Federails::Activity.includes(:actor).where(action: "Like", entity: [self] + comments.where(system: true), "actor.local": false).count # rubocop:disable Pundit/UsePolicyScope
  update_attribute(:like_count, count) # rubocop:disable Rails/SkipsModelValidations
end