Class: Assistant::TechnicalSupport::CaseReplayBatch
- Inherits:
-
Object
- Object
- Assistant::TechnicalSupport::CaseReplayBatch
- Includes:
- Service
- Defined in:
- app/services/assistant/technical_support/case_replay_batch.rb
Overview
Selects and runs enough automatic case replays to produce a requested
number of completed evaluations. Skipped/ineligible cases and operational
failures do not consume the target; assessed Sunny failures do, because
those are the article-improvement signal this exercise is meant to find.
Defined Under Namespace
Constant Summary collapse
- CANDIDATE_MULTIPLIER =
5- MAX_EVALUATIONS =
CaseCandidateSelector::DEFAULT_LIMIT
- COMMUNICATION_INCLUDES =
[ :uploads, { sender_party: :contact_points }, { recipient_party: :contact_points } ].freeze
- ACTIVITY_INCLUDES =
[ :activity_type, :activity_result_type, :uploads, { creator: :contact_points }, { closed_by: :contact_points }, { party: :contact_points }, { customer: :contact_points }, { assigned_resource: :contact_points }, { call_record: [ { origin_party: :contact_points }, { destination_party: :contact_points } ] }, { communication: COMMUNICATION_INCLUDES }, { triggered_communications: COMMUNICATION_INCLUDES } ].freeze
- RMA_INCLUDES =
[ :uploads, { activities: ACTIVITY_INCLUDES }, { communications: COMMUNICATION_INCLUDES }, { rma_items: %i[returned_item uploads] } ].freeze
- EVIDENCE_INCLUDES =
[ :service_address, :uploads, { assigned_to: :contact_points }, { creator: :contact_points }, { updater: :contact_points }, { activities: ACTIVITY_INCLUDES }, { communications: COMMUNICATION_INCLUDES }, { orders: { line_items: :item } }, { quotes: { line_items: :item } }, { rmas: RMA_INCLUDES }, { order_rmas: RMA_INCLUDES }, { room_configurations: %i[heating_system_product_line quoted_heating_system_pl] }, { support_case_participants: { party: [:contact_points, { customer: :contact_points }] } } ].freeze
Instance Method Summary collapse
-
#call ⇒ Result
Selection audit plus the attempted replay results.
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Method Details
#call ⇒ Result
Returns selection audit plus the attempted replay results.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'app/services/assistant/technical_support/case_replay_batch.rb', line 97 def call requested = target.to_i.clamp(1, MAX_EVALUATIONS) selection = candidate_selector.call( limit: [requested * CANDIDATE_MULTIPLIER, CaseCandidateSelector::MAX_LIMIT].min, family_balance_limit: requested ) attempts = [] evaluated_count = 0 selection.selections.each do |candidate| result = replay_service.call( support_case: support_case_for(candidate.support_case_id), account: ) attempt = Attempt.new(selection: candidate, result:) attempts << attempt evaluated_count += 1 if attempt.evaluated? break if evaluated_count >= requested end Result.new(selection:, attempts:) end |