Rescore bubble from Message, not Comment
This commit is contained in:
@@ -5,12 +5,12 @@ module Bubble::Commentable
|
||||
scope :ordered_by_comments, -> { order comments_count: :desc }
|
||||
end
|
||||
|
||||
def comment_captured
|
||||
def comment_created
|
||||
increment! :comments_count
|
||||
rescore
|
||||
end
|
||||
|
||||
def comment_uncaptured
|
||||
def comment_destroyed
|
||||
decrement! :comments_count
|
||||
rescore
|
||||
end
|
||||
|
||||
@@ -4,12 +4,4 @@ class Comment < ApplicationRecord
|
||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||
|
||||
searchable_by :body, using: :comments_search_index
|
||||
|
||||
def captured_as(message)
|
||||
message.bubble.comment_captured
|
||||
end
|
||||
|
||||
def uncaptured_as(message)
|
||||
message.bubble.comment_uncaptured
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,10 +7,4 @@ module Messageable
|
||||
has_one :message, as: :messageable, touch: true
|
||||
has_one :bubble, through: :message
|
||||
end
|
||||
|
||||
def captured_as(...)
|
||||
end
|
||||
|
||||
def uncaptured_as(...)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,15 +5,15 @@ class Message < ApplicationRecord
|
||||
|
||||
scope :chronologically, -> { order created_at: :asc, id: :desc }
|
||||
|
||||
after_create :captured
|
||||
after_destroy :uncaptured
|
||||
after_create :created
|
||||
after_destroy :destroyed
|
||||
|
||||
private
|
||||
def captured
|
||||
messageable.captured_as(self)
|
||||
def created
|
||||
bubble.comment_created if comment?
|
||||
end
|
||||
|
||||
def uncaptured
|
||||
messageable.uncaptured_as(self)
|
||||
def destroyed
|
||||
bubble.comment_destroyed if comment?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user