Class: Report::KpiTimeOnTask::KpiTimeOnTaskCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::KpiTimeOnTask::KpiTimeOnTaskCommand
- Defined in:
- app/services/report/kpi_time_on_task/kpi_time_on_task_command.rb
Overview
Command pattern to encapsulate parameters necessary to run a presence report
Instance Method Summary collapse
-
#execute ⇒ Object
Run the report with the given filters and store the result.
-
#success? ⇒ Boolean
Whether the command validated and ran successfully.
-
#to_csv ⇒ String
Render the report rows as CSV.
Instance Method Details
#execute ⇒ Object
Run the report with the given filters and store the result.
12 13 14 15 16 |
# File 'app/services/report/kpi_time_on_task/kpi_time_on_task_command.rb', line 12 def execute return unless valid? @result = Report::KpiTimeOnTask::KpiTimeOnTask.result_report(attributes) end |
#success? ⇒ Boolean
Whether the command validated and ran successfully.
37 38 39 |
# File 'app/services/report/kpi_time_on_task/kpi_time_on_task_command.rb', line 37 def success? valid? && @result.success? end |
#to_csv ⇒ String
Render the report rows as CSV.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/report/kpi_time_on_task/kpi_time_on_task_command.rb', line 20 def to_csv return unless valid? @result = Report::KpiTimeOnTask::KpiTimeOnTask.result_report(attributes) return if @result.data.blank? attributes = @result.data.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.data.each do |r| csv << r end end end |