Class: Customer::Watch
- Inherits:
-
BaseService
- Object
- BaseService
- Customer::Watch
- Defined in:
- app/services/customer/watch.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- WATCH_CAP =
2_000- WATCH_STATES =
%w[prospect customer]
- UNWATCHABLE_PROFILE_IDS =
[ProfileConstants::HOMEOWNER]
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Watch
constructor
A new instance of Watch.
-
#process(options = {}) ⇒ Object
This key method will perform 5 essential functions 1.
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
#initialize(options = {}) ⇒ Watch
Returns a new instance of Watch.
10 11 12 13 14 15 |
# File 'app/services/customer/watch.rb', line 10 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 = {}) ⇒ Object
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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/customer/watch.rb', line 24 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 |