Class: PartyEnrichmentWorker
- Inherits:
-
Object
- Object
- PartyEnrichmentWorker
- Includes:
- Sidekiq::Job, Sidekiq::Status::Worker
- Defined in:
- app/workers/party_enrichment_worker.rb
Overview
Sidekiq worker that drives a PartyResearchRun through its adapters.
Uses sidekiq-status so the CRM "Enrich" UI can poll job progress and
show per-adapter status. Two pieces of metadata are exposed:
at(idx, total) — overall progress for the progress bar
store(adapter: name) — the adapter currently running, for the label
Retries are set to 1 because a research run is user-initiated and any
failure should surface to the user immediately rather than silently
retrying for 20 minutes. The run row is transitioned to failed with the
exception message on uncaught errors.
Instance Method Summary collapse
-
#perform(run_id) ⇒ Object
Runs the job.
Instance Method Details
#perform(run_id) ⇒ Object
Runs the job.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/workers/party_enrichment_worker.rb', line 25 def perform(run_id) run = PartyResearchRun.find(run_id) PartyResearch::Orchestrator.call( run: run, on_progress: ->(idx, total, adapter_name) { at(idx, total) store(adapter: adapter_name, completed_adapters: idx) } ) store(adapter: 'done', completed_adapters: run.adapters_list.size) end |