Class: Report::MissedCalls::MissedCalls

Inherits:
Object
  • Object
show all
Defined in:
app/services/report/missed_calls/missed_calls.rb

Overview

Service object: missed calls.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.result_report(options = {}) ⇒ Result

Returns missed call data.

Parameters:

  • options (Hash) (defaults to: {})

    report filter options

Options Hash (options):

  • period1_gteq (Date)

    start of the reporting period

  • period1_lteq (Date)

    end of the reporting period

  • employee_ids (Array<Integer>)

    employees to include (blank entries ignored)

  • result_type_filter (String)

    result type filter

Returns:

  • (Result)

    missed call data



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/report/missed_calls/missed_calls.rb', line 21

def self.result_report(options = {})
  start_time = options[:period1_gteq].beginning_of_day
  end_time = options[:period1_lteq].end_of_day
  employee_ids = options[:employee_ids].filter_map(&:presence)

  data_result = QueueCallLog.where(start_time: start_time..end_time)
                            .where("outcome = 'missed' and enter_position is not null and ring_time > 1")

  data_result = data_result.where("member_party_id in (#{employee_ids.map(&:to_i).join(',')})") if employee_ids.present?

  case options[:result_type_filter]
  when 'completed'     then data_result = data_result.where(result_type: 'completed')
  when 'not_completed' then data_result = data_result.where.not(result_type: 'completed')
  end

  Result.new(success: true, data: data_result)
end