Class: Report::CallStatistics::CallStatResultSummary

Inherits:
CallStatResult show all
Defined in:
app/services/report/call_statistics/call_stat_result_summary.rb

Overview

Service object: call stat result summary.

Instance Method Summary collapse

Methods inherited from CallStatResult

#ext_conn_talk_time_humanized, #format_time_for_humans, #inbound_direct_talk_time_humanized, #inbound_from_queue_talk_time_humanized, #outbound_talk_time_humanized, #ttl_outbound_talk_time_humanized

Instance Method Details

#add_direct_inbound_talk_time(seconds) ⇒ Object

Add direct inbound talk time.

Parameters:

  • seconds (Integer)

Returns:

  • (Object)


55
56
57
58
59
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 55

def add_direct_inbound_talk_time(seconds)
  return unless seconds && seconds > 0

  inbound_direct_talk_times << seconds
end

#add_ext_conn_talk_time(seconds) ⇒ Object

Add ext conn talk time.

Parameters:

  • seconds (Integer)

Returns:

  • (Object)


46
47
48
49
50
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 46

def add_ext_conn_talk_time(seconds)
  return unless seconds && seconds > 0

  ext_conn_talk_times << seconds
end

#add_outbound_talk_time(seconds) ⇒ Object

Add outbound talk time.

Parameters:

  • seconds (Integer)

Returns:

  • (Object)


37
38
39
40
41
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 37

def add_outbound_talk_time(seconds)
  return unless seconds && seconds > 0

  outbound_talk_times << seconds
end

#add_queue_inbound_talk_time(seconds) ⇒ Object

Add queue inbound talk time.

Parameters:

  • seconds (Integer)

Returns:

  • (Object)


64
65
66
67
68
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 64

def add_queue_inbound_talk_time(seconds)
  return unless seconds && seconds > 0

  inbound_from_queue_talk_times << seconds
end

#average_inbound_direct_talk_time_humanizedObject

Average inbound direct talk time humanized.

Returns:

  • (Object)


103
104
105
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 103

def average_inbound_direct_talk_time_humanized
  format_time_for_humans average_inbound_direct_talk_time_in_seconds
end

#average_inbound_direct_talk_time_in_secondsInteger

Average inbound direct talk time in seconds.

Returns:

  • (Integer)


81
82
83
84
85
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 81

def average_inbound_direct_talk_time_in_seconds
  inbound_direct_talk_times.presence&.delete(0)
  idtt = inbound_direct_talk_times.present? ? inbound_direct_talk_times.average : 0
  idtt.floor
end

#average_inbound_from_queue_talk_time_in_secondsInteger

Average inbound from queue talk time in seconds.

Returns:

  • (Integer)


89
90
91
92
93
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 89

def average_inbound_from_queue_talk_time_in_seconds
  inbound_from_queue_talk_times.presence&.delete(0)
  ifqtt = inbound_from_queue_talk_times.present? ? inbound_from_queue_talk_times.average : 0
  ifqtt.floor
end

#average_inbound_from_queue_talk_times_humanizedObject

Average inbound from queue talk times humanized.

Returns:

  • (Object)


109
110
111
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 109

def average_inbound_from_queue_talk_times_humanized
  format_time_for_humans average_inbound_from_queue_talk_time_in_seconds
end

#average_outbound_talk_time_humanizedObject

Average outbound talk time humanized.

Returns:

  • (Object)


97
98
99
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 97

def average_outbound_talk_time_humanized
  format_time_for_humans average_outbound_talk_time_in_seconds
end

#average_outbound_talk_time_in_secondsInteger

Average outbound talk time in seconds.

Returns:

  • (Integer)


72
73
74
75
76
77
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 72

def average_outbound_talk_time_in_seconds
  outbound_talk_times.presence&.delete(0)
  ext_conn_talk_times.presence&.delete(0)
  ott = outbound_talk_times.none? ? 0 : ((outbound_talk_times.sum - ext_conn_talk_times.sum) / outbound_talk_times.count)
  ott.floor
end

#ext_conn_talk_time_in_secondsInteger

Ext conn talk time in seconds.

Returns:

  • (Integer)


18
19
20
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 18

def ext_conn_talk_time_in_seconds
  ext_conn_talk_times.sum
end

#inbound_direct_talk_time_in_secondsInteger

Inbound direct talk time in seconds.

Returns:

  • (Integer)


24
25
26
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 24

def inbound_direct_talk_time_in_seconds
  inbound_direct_talk_times.sum
end

#inbound_from_queue_talk_time_in_secondsInteger

Inbound from queue talk time in seconds.

Returns:

  • (Integer)


30
31
32
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 30

def inbound_from_queue_talk_time_in_seconds
  inbound_from_queue_talk_times.sum
end

#outbound_talk_time_in_secondsInteger

Outbound talk time in seconds.

Returns:

  • (Integer)


12
13
14
# File 'app/services/report/call_statistics/call_stat_result_summary.rb', line 12

def outbound_talk_time_in_seconds
  outbound_talk_times.sum
end