defmodule Mix.Tasks.Hrrr.PurgeGridPoints do
  @shortdoc "Delete every `is_grid_point = true` row from hrrr_profiles"

  @moduledoc """
  Removes every `is_grid_point = true` row from `hrrr_profiles` across every
  partition. The propagation grid now lives in `/data/scores` binary files,
  nothing reads grid-point rows anymore, and the grid worker no longer writes
  them — this task reclaims the disk space from the legacy data that
  accumulated before the April 14 cutover.

  Leaves `is_grid_point = false` (QSO-linked) rows untouched.

      mix hrrr.purge_grid_points
  """

  use Mix.Task

  alias Microwaveprop.Weather

  @impl Mix.Task
  def run(_argv) do
    Mix.Task.run("app.start")

    Mix.shell().info("Purging grid-point rows from hrrr_profiles...")
    deleted = Weather.purge_grid_point_profiles()
    Mix.shell().info("Purged #{deleted} grid-point rows total.")
  end
end
