Class: Report::CustomerPerformanceCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::CustomerPerformanceCommand
- Defined in:
- app/services/report/customer_performance_command.rb
Overview
Command pattern to encapsulate parameters necessary to run a presence report
Instance Method Summary collapse
-
#customer_identity_grouping? ⇒ Boolean
Whether customer identity grouping.
-
#execute ⇒ Object
Run the report with the given filters and store the result.
-
#grouping_options ⇒ Object
Grouping options.
-
#period1_humanized ⇒ Object
Period1 humanized.
-
#period1_range ⇒ Object
Period1 range.
-
#period2_humanized ⇒ Object
Period2 humanized.
-
#period2_range ⇒ Object
Period2 range.
-
#periods ⇒ Object
Periods.
-
#success? ⇒ Boolean
Whether the command validated and ran successfully.
Instance Method Details
#customer_identity_grouping? ⇒ Boolean
Whether customer identity grouping.
37 38 39 |
# File 'app/services/report/customer_performance_command.rb', line 37 def customer_identity_grouping? grouping.to_s == 'customer_identity' end |
#execute ⇒ Object
Run the report with the given filters and store the result.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/report/customer_performance_command.rb', line 20 def execute return unless valid? @results = Report::CustomerPerformance.new( periods: periods, grouping: grouping.to_sym, report_groupings: report_groupings, buying_group_ids: , profile_ids: profile_ids, company_ids: company_ids, state_codes: state_codes, primary_sales_rep_ids: primary_sales_rep_ids ).perform end |
#grouping_options ⇒ Object
Grouping options.
82 83 84 |
# File 'app/services/report/customer_performance_command.rb', line 82 def Report::CustomerPerformance::GROUPINGS end |
#period1_humanized ⇒ Object
Period1 humanized.
64 65 66 |
# File 'app/services/report/customer_performance_command.rb', line 64 def period1_humanized "From #{period1_range.first} until #{period1_range.last}" end |
#period1_range ⇒ Object
Period1 range.
52 53 54 |
# File 'app/services/report/customer_performance_command.rb', line 52 def period1_range (period1_gteq && period1_lteq && period1_gteq)..period1_lteq end |
#period2_humanized ⇒ Object
Period2 humanized.
70 71 72 |
# File 'app/services/report/customer_performance_command.rb', line 70 def period2_humanized "From #{period2_range.first} until #{period2_range.last}" end |
#period2_range ⇒ Object
Period2 range.
58 59 60 |
# File 'app/services/report/customer_performance_command.rb', line 58 def period2_range (period2_gteq && period2_lteq && period2_gteq)..period2_lteq end |
#periods ⇒ Object
Periods.
43 44 45 46 47 48 |
# File 'app/services/report/customer_performance_command.rb', line 43 def periods p = [] p << period1_range p << period2_range if period2_gteq.present? && period2_lteq.present? p end |
#success? ⇒ Boolean
Whether the command validated and ran successfully.
76 77 78 |
# File 'app/services/report/customer_performance_command.rb', line 76 def success? valid? && @results.success? end |