Class: DailyCallRecordTranscriptionWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/daily_call_record_transcription_worker.rb

Overview

Daily catch-up worker for call record transcriptions.

Primary transcription is queued immediately when call records are imported
via CallRecord::SwitchvoxImporterFile. This worker serves as a safety net
to catch any records that were missed (e.g., queue issues, worker failures,
records created through other means).

Runs at 6 AM CT daily via sidekiq-cron.

The worker uses the ai_embeddings queue for controlled throughput
and to avoid impacting user-facing operations.

Cost estimate: ~$0.06/call (transcription + LeMUR + embedding)

Note: Backfill functionality is disabled by default to focus on recent calls.
To enable backfill, set BACKFILL_ENABLED = true below.

Constant Summary collapse

BACKFILL_ENABLED =

Set to true to enable backfilling older calls

false
BACKFILL_LIMIT =

Number of older calls to backfill per run

500
BACKFILL_DAYS_LIMIT =

Only process calls from the last N days for backfill (most recent first)
2 years = 730 days - older calls are not worth the cost

730

Instance Method Summary collapse

Instance Method Details

#performObject



34
35
36
37
38
39
40
41
42
# File 'app/workers/daily_call_record_transcription_worker.rb', line 34

def perform
  Rails.logger.info '[DailyCallRecordTranscriptionWorker] Starting catch-up transcription run'

  new_calls_count = process_new_calls
  backfill_count = BACKFILL_ENABLED ? backfill_older_calls : 0

  Rails.logger.info '[DailyCallRecordTranscriptionWorker] Completed: ' \
                    "#{new_calls_count} missed calls queued, #{backfill_count} backfilled"
end