Track events for new comments too
This commit is contained in:
@@ -5,8 +5,9 @@ module Bubble::Commentable
|
||||
scope :ordered_by_comments, -> { order comments_count: :desc }
|
||||
end
|
||||
|
||||
def comment_created
|
||||
def comment_created(comment)
|
||||
increment! :comments_count
|
||||
track_event :commented, comment_id: comment.id
|
||||
rescore
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Event < ApplicationRecord
|
||||
include Assignments, Stages
|
||||
include Assignments, Comment, Stages
|
||||
|
||||
belongs_to :creator, class_name: "User"
|
||||
belongs_to :summary, touch: true, class_name: "EventSummary"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
module Event::Comment
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
store_accessor :particulars, :comment_id
|
||||
end
|
||||
|
||||
def comment
|
||||
@comment ||= Comment.find(comment_id)
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@ class Message < ApplicationRecord
|
||||
|
||||
private
|
||||
def created
|
||||
bubble.comment_created if comment?
|
||||
bubble.comment_created(comment) if comment?
|
||||
end
|
||||
|
||||
def destroyed
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Notifier::Commented < Notifier
|
||||
private
|
||||
def body
|
||||
"#{creator.name} commented on: #{bubble.title}"
|
||||
end
|
||||
|
||||
def recipients
|
||||
bubble.bucket.users.without(creator)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user