Background Jobs
Background processing uses Sidekiq. Jobs are defined in app/jobs/ and inherit from ApplicationJob.
Sidekiq Configuration
Defined in config/sidekiq.yml:
concurrency: 5
queues:
- default
- low
- high
- llm
Queue Usage
| Queue | Purpose |
|---|---|
default |
General work: audio prep, card association, document processing |
llm |
AI/LLM operations: verb validation, translation, conjugation generation |
low |
Non-urgent: metrics refresh |
high |
Priority tasks (defined but not heavily used) |
Jobs by Namespace
Resources: Verbs (app/jobs/resources/verbs/)
ValidateCommonJob(queue:llm) – Classifies verb commonality viaCommonClassifierServiceValidateConjugationsJob(queue:llm) – Generates conjugations viaConjugationsGeneratorServiceValidateTranslationsJob(queue:llm) – Generates translations viaTranslationsGeneratorServiceValidateVerbalsJob– Generates verbal formsPrepareAudioJob– Generates TTS audio via AWS Polly
Resources: Conjugations (app/jobs/resources/conjugations/)
FindSentenceMatchesJob– Finds sentences containing the conjugationGenerateSentenceJob– Generates example sentences via LLM, broadcasts via Turbo StreamsPrepareSentenceAudioJob– Generates audio for matched sentences
Resources: Documents (app/jobs/resources/documents/)
ProcessJob– Orchestrates document processing (segment, tokenize, evaluate level)RelateDocumentSentenceJob– Links sentences to documentsRelateDocumentWordJob– Links words to documents
Resources: Infinitives (app/jobs/resources/infinitives/)
FindSentenceMatchesJob– Finds sentences containing the infinitive
Decks (app/jobs/decks/)
Cards::AssociationJob– Associates sentences and audio to cardsAuditAudioJob– Audits deck audio completeness (optional S3 verification)
Reporting (app/jobs/reporting/)
UserMetricsRefreshJob(queue:low) – Refreshes aggregated user metrics for the admin dashboard
Info (app/jobs/info/)
GeocodeContactJob– Resolves contact IP to city/region/country via Geocoder
Patterns
- Jobs are thin orchestrators that delegate to service objects
- Error handling:
ActiveRecord::RecordNotFoundis logged and swallowed; other exceptions are logged and re-raised - Some jobs track their Sidekiq JID on parent models (e.g.,
deck.active_job_id) - Turbo Streams broadcasts are used for real-time UI updates from jobs