Class: Customer::Watch
- Inherits:
-
BaseService
- Object
- BaseService
- Customer::Watch
- Defined in:
- app/services/customer/watch.rb
Overview
Service object: watch.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- WATCH_CAP =
Watch cap.
2_000- WATCH_STATES =
Recognised watch states.
%w[prospect customer].freeze
- UNWATCHABLE_PROFILE_IDS =
Unwatchable profile ids.
[ProfileConstants::HOMEOWNER].freeze
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Watch
constructor
A new instance of Watch.
-
#process(options = {}) ⇒ Result
This key method will perform 5 essential functions 1.
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger
Constructor Details
#initialize(options = {}) ⇒ Watch
Returns a new instance of Watch.
18 19 20 21 22 23 |
# File 'app/services/customer/watch.rb', line 18 def initialize( = {}) super @open_activity_flag_resetter = Customer::ResetOpenActivityFlag.new(logger:) @fill_sales_activity = Customer::FillSalesActivity.new(logger:) @prune_touchbase = Customer::PruneTouchbase.new(logger:) end |
Instance Method Details
#process(options = {}) ⇒ Result
This key method will perform 5 essential functions
- The open sales activity flag will be calculated for all of a rep's accounts. Pass :skip_calculate_open_activity => true to skip
- Each customer in the sales rep account base will be scored and the result stored in the Sales Priority index. Pass :skip_scoring => true to skip
- The top 2000 customers by Sales Priority Index are marked as watched accounts minus those on forced watch. Pass :skip_reset_sales_watch => true to skip
- A touchbase sales activity is filled in on all watched accounts who don't have one. The new activites are prioritized from their assignement date 6 weeks from now. Pass :skip_fill_sales_activity => true to skip
- Past due activities are prioritized and distributed starting the next business day. Pass :skip_prioritization => true to skip
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/services/customer/watch.rb', line 39 def process( = {}) = .with_indifferent_access logger.debug("Processing full reset for sales watch", employee_id: [:employee_id]) reset_sales_watch_for_unassigned reset_sales_watch_for_invalid_states score_customers(employee_id: [:employee_id]) unless [:skip_scoring] employees = Employee.all employees = if [:employee_id] employees.where(id: [:employee_id]) else employees.active_employees.sales_reps.sorted end employees.each do |e| logger.info "Processing full reset for employee #{e.full_name}/#{e.id}" reset_sales_watch_list(e.id) unless [:skip_reset_sales_watch] fill_sales_activity(e.id) unless [:skip_fill_sales_activity] reset_open_activity_flag(employee_id: e.id) unless [:skip_calculate_open_activity] end # Prune must go through all to be effective (since rep might drop off accounts), unless the watch method is # called on a specific employee in which case the focus will be narrowed prune_touchbase(primary_sales_rep_id: [:employee_id]) unless [:skip_prune_touchbase] Result.new(success: true) end |