Class: Customer::PruneTouchbase
- Inherits:
-
BaseService
- Object
- BaseService
- Customer::PruneTouchbase
- Defined in:
- app/services/customer/prune_touchbase.rb
Overview
Cancels touchbase for accounts not on watch list
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(**options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/customer/prune_touchbase.rb', line 7 def process(**) logger.debug("Cancelling TOUCHBASE for accounts out of watch") employee_ids = {} activities = Activity.where(activity_type_id: ActivityTypeConstants::TOUCHBASE_ID). open_activities. joins(:customer). where(Customer[:watch].in([Customer.watches[:not_watched_auto], Customer.watches[:not_watched_forced]])) activities = activities.where(Customer[:primary_sales_rep_id].eq([:primary_sales_rep_id])) if [:primary_sales_rep_id].present? activities = activities.where(customer_id: [:customer_ids]) if [:customer_ids].present? activities = activities.where(party_id: [:party_ids]) if [:party_ids].present? activities = activities.limit([:limit]) if [:limit] activities_processed = activities.size logger.debug("Found activities to cancel", count: activities_processed) activities.find_each do |activity| logger.debug("Cancelling activity", activity_id: activity.id) activity.cancel unless [:dry_run] end return Result.new(success: true, activities_removed: activities_processed) end |