Class: CallRecordSummaryWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/call_record_summary_worker.rb

Overview

Note:

Call analysis is automatically triggered by TranscriptionService,
so this worker is primarily used for manual re-analysis.

Background worker for running call analysis on transcripts.
Uses the LLM for comprehensive analysis (summary, action items, etc.).

Examples:

Queue analysis

CallRecordSummaryWorker.perform_async(call_record_id: 123)

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    job options

Options Hash (options):

  • call_record_id (Integer)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/workers/call_record_summary_worker.rb', line 18

def perform(options = {})
  call_record_id = options[:call_record_id]

  unless call_record_id
    Rails.logger.error '[CallRecordSummaryWorker] Missing call_record_id'
    return
  end

  call_record = CallRecord.find_by(id: call_record_id)
  unless call_record
    Rails.logger.error "[CallRecordSummaryWorker] CallRecord #{call_record_id} not found"
    return
  end

  if call_record.assemblyai_transcript_id.blank?
    Rails.logger.info "[CallRecordSummaryWorker] No AssemblyAI transcript for CallRecord #{call_record_id}, skipping"
    return
  end

  Rails.logger.info "[CallRecordSummaryWorker] Running call analysis for CallRecord #{call_record_id}"

  # Run call analysis via TranscriptionService
  service = CallRecordProcessing::TranscriptionService.new(call_record)
  service.run_call_analysis(call_record.assemblyai_transcript_id)

  Rails.logger.info "[CallRecordSummaryWorker] Call analysis completed for CallRecord #{call_record_id}"

  # Regenerate embedding with enriched content
  EmbeddingWorker.perform_async('CallRecord', call_record_id)
end