Class: Report::KpiCall::KpiCallCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::KpiCall::KpiCallCommand
- Defined in:
- app/services/report/kpi_call/kpi_call_command.rb
Overview
Command pattern to encapsulate parameters necessary to run a presence report
Constant Summary collapse
- KPI_LIST =
[ ['TIME ON AVAILABLE', 1], ['INBOUNDS', 2], ['OUTBOUNDS', 3], ['ACTIVITIES', 4], ['SMS', 5], ['LOOM/ZOOM Clip', 6], ['CALL BLOCKS', 7], ['EMAILS', 8], ['MISSED CALLS %', 9] ].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.select_weeks ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 80 def self.select_weeks week_and_dates = [] (Date.current.beginning_of_year.years_ago(1)..Date.current.to_date).each do |d| week_number = Date.new(d.year, d.month, d.day).cweek block = week_number.even? == true ? 'A' : 'B' week_and_dates << [('Week ' + week_number.to_s + ' ---> From ' + d.beginning_of_week.to_s + ' to ' + d.end_of_week.days_ago(2).to_s + ' (Block ' + block + ')'), (d.beginning_of_week.to_s + '/' + d.end_of_week.days_ago(2).to_s + '/' + block)] end week_and_dates.uniq.compact end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 22 def execute return unless valid? @result = Report::KpiCall::KpiCall.result_report(attributes) end |
#success? ⇒ Boolean
43 44 45 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 43 def success? valid? && @result.success? end |
#to_csv ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 28 def to_csv return unless valid? @result = Report::KpiCall::KpiCall.result_report(attributes) return unless @result.data_csv.present? attributes = @result.data_csv.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.data_csv.each do |r| csv << r end end end |