Class: Report::MissedCalls::MissedCalls

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

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.result_report(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/report/missed_calls/missed_calls.rb', line 8

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].map(&:presence).compact

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

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

  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