prop/lib/mix/tasks/reset_enrichment.ex
Graham McIntire 55a51f69ab
Replace boolean enrichment flags with enum status fields
- New fields: hrrr_status, weather_status, terrain_status, iemre_status
  with values: pending, queued, processing, complete, failed, unavailable
- EnrichmentStatus module defines valid state transitions
- Migration backfills: queued=true → complete, false → pending
- Workers set status on transitions (queued on enqueue, complete on finish)
- Show page reads status from contact struct, not computed dynamically
- Backfill dashboard queries status fields for accurate progress counts
- Remove cron-scheduled ContactWeatherEnqueueWorker (enrichment only on
  submission, page view, or manual backfill)
- Partial indexes on status != 'complete' for fast unprocessed lookups
2026-04-02 12:07:51 -05:00

33 lines
958 B
Elixir

defmodule Mix.Tasks.ResetEnrichment do
@shortdoc "Reset weather/HRRR/IEMRE enrichment flags for re-processing"
@moduledoc """
Resets weather, HRRR, and IEMRE enrichment flags on all QSOs so the
next enqueue worker run re-processes them with multi-point path data.
Does NOT reset terrain_queued since terrain profiles are path-based (pos1→pos2)
and don't change with multi-point enrichment.
mix reset_enrichment
"""
use Mix.Task
import Ecto.Query
alias Microwaveprop.Radio.Contact
alias Microwaveprop.Repo
@impl Mix.Task
def run(_args) do
Mix.Task.run("app.start")
{count, _} =
Contact
|> where([q], q.weather_status != :pending or q.hrrr_status != :pending or q.iemre_status != :pending)
|> Repo.update_all(set: [weather_status: "pending", hrrr_status: "pending", iemre_status: "pending"])
Mix.shell().info("Reset enrichment status to :pending on #{count} contacts")
:ok
end
end