Class: Telephony::Jobs::AgentOffline

Inherits:
Object
  • Object
show all
Defined in:
lib/telephony/jobs/agent_offline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, timestamp) ⇒ AgentOffline

Returns a new instance of AgentOffline.



6
7
8
9
# File 'lib/telephony/jobs/agent_offline.rb', line 6

def initialize id, timestamp
  @id = id
  @timestamp = timestamp
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/telephony/jobs/agent_offline.rb', line 4

def id
  @id
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/telephony/jobs/agent_offline.rb', line 4

def timestamp
  @timestamp
end

Instance Method Details

#failureObject



21
22
23
24
25
# File 'lib/telephony/jobs/agent_offline.rb', line 21

def failure
  Rails.logger.error "#{self.class}: #{self.as_json}"
  ActiveSupport::Notifications
    .instrument("telephony.agent_offline_failure", self)
end

#performObject



17
18
19
# File 'lib/telephony/jobs/agent_offline.rb', line 17

def perform
  update_status
end

#update_statusObject



11
12
13
14
15
# File 'lib/telephony/jobs/agent_offline.rb', line 11

def update_status
  Agent.find_with_lock(id) do |agent|
    agent.update_status_by_event Agent::OFFLINE, timestamp
  end
end