Track events for new comments too

This commit is contained in:
Kevin McConnell
2025-01-09 18:06:45 +00:00
parent 5a56c16029
commit a082eb75f5
5 changed files with 25 additions and 3 deletions
+2 -1
View File
@@ -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
View File
@@ -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"
+11
View File
@@ -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
+1 -1
View File
@@ -10,7 +10,7 @@ class Message < ApplicationRecord
private
def created
bubble.comment_created if comment?
bubble.comment_created(comment) if comment?
end
def destroyed
+10
View File
@@ -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