Class: Assistant::TechnicalSupport::CaseEvidenceUploadQuery
- Inherits:
-
Object
- Object
- Assistant::TechnicalSupport::CaseEvidenceUploadQuery
- Defined in:
- app/queries/assistant/technical_support/case_evidence_upload_query.rb
Overview
Finds extractable attachments that belong to the complete evidence stream
for resolved Technical Support replay cases. The Upload rows remain the
source of truth; this query only feeds the existing Markdown extraction
worker so missing derived text can heal unattended.
Constant Summary collapse
- SUPPORTED_EXTENSION_PATTERN =
begin extensions = DoclingClient::SUPPORTED_EXTENSIONS.map { |extension| Regexp.escape(extension) } "(?:#{extensions.join('|')})$" end.freeze
Instance Method Summary collapse
-
#call(since: TechnicalSupportReplayCriteria::LOOKBACK.ago) ⇒ ActiveRecord::Relation<Upload>
Newest missing extractions first.
-
#initialize(scope: Upload.all, case_scope: SupportCase.all) ⇒ CaseEvidenceUploadQuery
constructor
A new instance of CaseEvidenceUploadQuery.
Constructor Details
#initialize(scope: Upload.all, case_scope: SupportCase.all) ⇒ CaseEvidenceUploadQuery
Returns a new instance of CaseEvidenceUploadQuery.
15 16 17 18 |
# File 'app/queries/assistant/technical_support/case_evidence_upload_query.rb', line 15 def initialize(scope: Upload.all, case_scope: SupportCase.all) @scope = scope @case_scope = case_scope end |
Instance Method Details
#call(since: TechnicalSupportReplayCriteria::LOOKBACK.ago) ⇒ ActiveRecord::Relation<Upload>
Returns newest missing extractions first.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/queries/assistant/technical_support/case_evidence_upload_query.rb', line 22 def call(since: TechnicalSupportReplayCriteria::LOOKBACK.ago) case_ids = eligible_case_ids(since) rma_ids = (case_ids) activity_ids = (case_ids, rma_ids) communication_ids = (case_ids, rma_ids, activity_ids) rma_item_ids = RmaItem.where(rma_id: rma_ids).select(:id) direct_ids = scope .where(direct_upload_predicate(case_ids, activity_ids, rma_ids, rma_item_ids)) .select(:id) communication_upload_ids = Upload .joins(:communications) .where(communications: { id: communication_ids }) .select(:id) scope .where(id: direct_ids) .or(scope.where(id: communication_upload_ids)) .where(extracted_markdown: nil) .where.not(attachment_uid: [nil, '']) .where(scope.arel_table[:attachment_name].lower.matches_regexp(SUPPORTED_EXTENSION_PATTERN)) .order(created_at: :desc, id: :desc) end |