Class: Report::CallStatistics::Command
Overview
Constant Summary
Constants inherited
from BaseCommand
BaseCommand::ARRAY_TYPE_NAMES
Instance Attribute Summary
Attributes inherited from BaseCommand
#results
Instance Method Summary
collapse
Methods inherited from BaseCommand
#[], #attributes, #email_parameters, #email_partial, #initialize
normalize
Instance Method Details
#departments=(new_departments) ⇒ Object
14
15
16
|
# File 'app/services/report/call_statistics/command.rb', line 14
def departments=(new_departments)
super((new_departments || []).filter_map(&:presence).uniq)
end
|
#employee_ids=(new_employee_ids) ⇒ Object
18
19
20
|
# File 'app/services/report/call_statistics/command.rb', line 18
def employee_ids=(new_employee_ids)
super((new_employee_ids || []).filter_map(&:presence).uniq)
end
|
#execute ⇒ Object
22
23
24
25
26
|
# File 'app/services/report/call_statistics/command.rb', line 22
def execute
return unless valid?
@result = Query.report(attributes.symbolize_keys)
end
|
#success? ⇒ Boolean
44
45
46
|
# File 'app/services/report/call_statistics/command.rb', line 44
def success?
valid? && @result.success?
end
|
#to_csv ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/services/report/call_statistics/command.rb', line 28
def to_csv
return unless valid?
@result = Query.report(attributes.symbolize_keys)
return if @result.individuals.blank?
attributes = @result.individuals.first.attributes.keys
CSV.generate(headers: true) do |csv|
csv << attributes
@result.individuals.each do |r|
csv << attributes.map { |attr| r.send(attr) }
end
end
end
|