Class: DailyCallRecordTranscriptionWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
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 CallRecordSwitchvoxImporterFile. 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: the AssemblyAI backfill is OFF by default. The day-to-day coverage gap
is now closed by the cheap Gemini pipeline (CallRecordBulkTranscriptionWorker,
min_age 7d), which sweeps anything older than the recent window. Enable this
backfill only for a deliberate full-feature (diarization + LeMUR) re-run of a
chosen recent window — either by passing args to perform_async or by adding
them to the daily_call_record_transcription cron entry. It uses the expensive
AssemblyAI path, so it is intentionally not the default backlog tool.

Examples:

Full-feature AssemblyAI backfill of the last 30 days (100 calls)

DailyCallRecordTranscriptionWorker.perform_async(
  'backfill' => true, 'backfill_days' => 30, 'backfill_limit' => 100
)

Constant Summary collapse

BACKFILL_ENABLED =

Defaults for the optional AssemblyAI backfill (overridable per-run via args).

false
BACKFILL_LIMIT =
500
BACKFILL_DAYS_LIMIT =

2 years = 730 days - older calls are not worth the AssemblyAI cost

730

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/workers/daily_call_record_transcription_worker.rb', line 40

def perform(options = {})
  options = options.symbolize_keys
  backfill_enabled = options.fetch(:backfill, BACKFILL_ENABLED)
  backfill_limit   = (options[:backfill_limit] || BACKFILL_LIMIT).to_i
  backfill_days    = (options[:backfill_days]  || BACKFILL_DAYS_LIMIT).to_i

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

  new_calls_count = process_new_calls
  backfill_count  = backfill_enabled ? backfill_older_calls(backfill_limit, backfill_days) : 0

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