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 =
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
82 83 84 85 86 87 88 89 90 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 82 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} ---> From #{d.beginning_of_week} to #{d.end_of_week.days_ago(2)} (Block #{block})", "#{d.beginning_of_week}/#{d.end_of_week.days_ago(2)}/#{block}"] end week_and_dates.uniq.compact end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 24 def execute return unless valid? @result = Report::KpiCall::KpiCall.result_report(attributes) end |
#success? ⇒ Boolean
45 46 47 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 45 def success? valid? && @result.success? end |
#to_csv ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/report/kpi_call/kpi_call_command.rb', line 30 def to_csv return unless valid? @result = Report::KpiCall::KpiCall.result_report(attributes) return if @result.data_csv.blank? 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 |