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:
Sojan Jose
2022-02-28 18:16:12 +05:30
committed by GitHub
parent 12c0be002e
commit 4260441f8c
21 changed files with 54 additions and 186 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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