Class: NewLead::ProtectLastOpenLeadActivity
- Inherits:
-
Object
- Object
- NewLead::ProtectLastOpenLeadActivity
- Includes:
- Service
- Defined in:
- app/services/new_lead/protect_last_open_lead_activity.rb
Overview
Prevents nightly invalid-activity maintenance from leaving a live lead with
no open lead follow-up. For lead activity types it owns the complete decision:
reconcile under a customer row lock, cancel while still holding that lock if
another lead task remains, or protect the final task. Non-lead activities
retain the existing direct cancellation path.
Constant Summary collapse
- Result =
Backwards-compatible result name scoped to the service.
NewLead::LeadActivityProtectionResult
Instance Method Summary collapse
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/new_lead/protect_last_open_lead_activity.rb', line 17 def call return Result.new(status: :resolved) unless current_open_activity? return invalidation_result(status: :not_applicable) unless live_lead? customer.with_lock do customer.reload activity.reload protect_or_invalidate end rescue StandardError => e report_error(e) Result.new(status: :guard_error) end |