Initial Commit

Co-authored-by: Subin <subinthattaparambil@gmail.com>
Co-authored-by: Manoj <manojmj92@gmail.com>
Co-authored-by: Nithin <webofnithin@gmail.com>
This commit is contained in:
Pranav Raj Sreepuram
2019-08-14 15:18:44 +05:30
commit 2a34255e0b
537 changed files with 27318 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
class Reports::UpdateAccountIdentity < Reports::UpdateIdentity
attr_reader :account
def initialize(account, timestamp = Time.now)
super(account, timestamp)
@identity = ::AccountIdentity.new(account.id)
end
end

View File

@@ -0,0 +1,9 @@
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

View File

@@ -0,0 +1,67 @@
class Reports::UpdateIdentity
attr_reader :account, :identity
attr_accessor :timestamp
def initialize(account, timestamp = Time.now)
@account, @timestamp = account, 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