Chore: clean up Reporting Events (#4044)
Tech debt clean up Fixes #4057 Co-authored-by: Aswin Dev P S <aswin@chatwoot.com>
This commit is contained in:
@@ -4,6 +4,6 @@ module Reportable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :events, dependent: :destroy_async
|
||||
has_many :reporting_events, dependent: :destroy
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,8 +39,8 @@ class Label < ApplicationRecord
|
||||
account.messages.where(conversation_id: conversations.pluck(:id))
|
||||
end
|
||||
|
||||
def events
|
||||
account.events.where(conversation_id: conversations.pluck(:id))
|
||||
def reporting_events
|
||||
account.reporting_events.where(conversation_id: conversations.pluck(:id))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: events
|
||||
# Table name: reporting_events
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# name :string
|
||||
@@ -14,14 +14,14 @@
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_events_on_account_id (account_id)
|
||||
# index_events_on_created_at (created_at)
|
||||
# index_events_on_inbox_id (inbox_id)
|
||||
# index_events_on_name (name)
|
||||
# index_events_on_user_id (user_id)
|
||||
# index_reporting_events_on_account_id (account_id)
|
||||
# index_reporting_events_on_created_at (created_at)
|
||||
# index_reporting_events_on_inbox_id (inbox_id)
|
||||
# index_reporting_events_on_name (name)
|
||||
# index_reporting_events_on_user_id (user_id)
|
||||
#
|
||||
|
||||
class Event < ApplicationRecord
|
||||
class ReportingEvent < ApplicationRecord
|
||||
validates :account_id, presence: true
|
||||
validates :name, presence: true
|
||||
validates :value, presence: true
|
||||
@@ -45,7 +45,7 @@ class Team < ApplicationRecord
|
||||
account.messages.where(conversation_id: conversations.pluck(:id))
|
||||
end
|
||||
|
||||
def events
|
||||
account.events.where(conversation_id: conversations.pluck(:id))
|
||||
def reporting_events
|
||||
account.reporting_events.where(conversation_id: conversations.pluck(:id))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user