prop/lib/microwaveprop/workers/pskr_recalibration_worker.ex
2026-06-16 12:38:08 -05:00

35 lines
1 KiB
Elixir

defmodule Microwaveprop.Workers.PskrRecalibrationWorker do
@moduledoc """
Weekly cron that runs `Pskr.Recalibrator` against the
PSKR calibration corpus.
Scheduled for Sunday 04:00 UTC (off-peak, after the climatology
rebuild and before the Monday-morning operator review window). At
fire time the recalibrator decides whether the corpus is dense
enough to bin — when it isn't, the run still records a row with
status `"skipped_insufficient_data"` so the audit trail captures
every fire.
Manual reruns: enqueue this worker with no args. It always
produces a fresh run record; previous runs stay queryable for
trend comparison.
"""
use Oban.Pro.Worker,
queue: :backfill_enqueue,
max_attempts: 3,
unique: [
period: 86_400,
states: :incomplete
]
alias Microwaveprop.Pskr.Recalibrator
require Logger
@impl Oban.Pro.Worker
def process(%Oban.Job{}) do
run = Recalibrator.run()
Logger.info("PskrRecalibrationWorker: status=#{run.status} sample_count=#{run.sample_count}")
:ok
end
end