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:
@@ -1,10 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Reports::UpdateAccountIdentity < Reports::UpdateIdentity
|
||||
attr_reader :account
|
||||
|
||||
def initialize(account, timestamp = Time.now)
|
||||
super(account, timestamp)
|
||||
@identity = ::AccountIdentity.new(account.id)
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Reports::UpdateAgentIdentity < Reports::UpdateIdentity
|
||||
attr_reader :agent
|
||||
|
||||
def initialize(account, agent, timestamp = Time.now)
|
||||
super(account, timestamp)
|
||||
@agent = agent
|
||||
@identity = ::AgentIdentity.new(agent.id, tags: { account_id: account.id })
|
||||
end
|
||||
end
|
||||
@@ -1,69 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Reports::UpdateIdentity
|
||||
attr_reader :account, :identity
|
||||
attr_accessor :timestamp
|
||||
|
||||
def initialize(account, timestamp = Time.now)
|
||||
@account = account
|
||||
@timestamp = timestamp
|
||||
end
|
||||
|
||||
def incr_conversations_count(step = 1)
|
||||
update_conversations_count(:incr, step)
|
||||
end
|
||||
|
||||
def decr_conversations_count(step = 1)
|
||||
update_conversations_count(:decr, step)
|
||||
end
|
||||
|
||||
def incr_incoming_messages_count(step = 1)
|
||||
update_incoming_messages_count(:incr, step)
|
||||
end
|
||||
|
||||
def decr_incoming_messages_count(step = 1)
|
||||
update_incoming_messages_count(:decr, step)
|
||||
end
|
||||
|
||||
def incr_outgoing_messages_count(step = 1)
|
||||
update_outgoing_messages_count(:incr, step)
|
||||
end
|
||||
|
||||
def decr_outgoing_messages_count(step = 1)
|
||||
update_outgoing_messages_count(:decr, step)
|
||||
end
|
||||
|
||||
def incr_resolutions_count(step = 1)
|
||||
update_resolutions_count(:incr, step)
|
||||
end
|
||||
|
||||
def decr_resolutions_count(step = 1)
|
||||
update_resolutions_count(:decr, step)
|
||||
end
|
||||
|
||||
def update_avg_first_response_time(response_time)
|
||||
identity.avg_first_response_time.set(response_time, timestamp)
|
||||
end
|
||||
|
||||
def update_avg_resolution_time(response_time)
|
||||
identity.avg_resolution_time.set(response_time, timestamp)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_conversations_count(method, step)
|
||||
identity.conversations_count.send(method, step, timestamp)
|
||||
end
|
||||
|
||||
def update_incoming_messages_count(method, step)
|
||||
identity.incoming_messages_count.send(method, step, timestamp)
|
||||
end
|
||||
|
||||
def update_outgoing_messages_count(method, step)
|
||||
identity.outgoing_messages_count.send(method, step, timestamp)
|
||||
end
|
||||
|
||||
def update_resolutions_count(method, step)
|
||||
identity.resolutions_count.send(method, step, timestamp)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user