Full cutover: the propagation_scores Postgres table is gone, and the binary files under /data/scores are the sole source of truth for the map render path. Three stacked changes: 1. New migration drops the propagation_scores table and its indexes (the earlier tuning migrations for it were already applied and are now no-ops against a missing table, which is fine — Ecto just runs them on fresh environments). 2. Propagation context is gutted of every GridScore reference. replace_scores/2 writes files only. upsert_scores/2 is deleted. load_scores_from_db, available_valid_times_from_db, point_detail_from_db, point_forecast_from_db, fetch_factors, coalesce_factors, the Postgres side of prune_old_scores, and the Postgres fallbacks in latest/earliest_valid_time are all removed. point_detail always returns an empty factors map now since factor breakdowns were retired with the table. 3. Deleted modules: - Propagation.GridScore (the schema) - Propagation.ScorerDiff (read factors from the table) - Propagation.AsosNudge (helper for AsosAdjustmentWorker) - Workers.AsosAdjustmentWorker (its cron was already disabled) - Mix.Tasks.ScorerDiff (wrapper around the deleted module) And their tests. AdminTaskWorker's scorer_diff task is a logging no-op so any queued Oban rows drain cleanly. Release.scorer_diff stays as a stub that tells the operator. propagation_prune_worker_test rewritten to exercise ScoresFile pruning. propagation_test.exs rewritten to use replace_scores + ScoresFile throughout (no more GridScore / upsert_scores paths).
34 lines
1.4 KiB
Elixir
34 lines
1.4 KiB
Elixir
defmodule Microwaveprop.Workers.PropagationPruneWorkerTest do
|
|
use Microwaveprop.DataCase, async: false
|
|
|
|
alias Microwaveprop.Propagation.ScoresFile
|
|
alias Microwaveprop.Workers.PropagationPruneWorker
|
|
|
|
describe "perform/1" do
|
|
test "deletes ScoresFile binaries with valid_time older than 2 hours" do
|
|
now = DateTime.utc_now()
|
|
old = now |> DateTime.add(-3, :hour) |> DateTime.truncate(:second)
|
|
fresh = now |> DateTime.add(-30, :minute) |> DateTime.truncate(:second)
|
|
future = now |> DateTime.add(6, :hour) |> DateTime.truncate(:second)
|
|
|
|
ScoresFile.write!(10_000, old, [%{lat: 25.0, lon: -125.0, score: 10}])
|
|
ScoresFile.write!(10_000, fresh, [%{lat: 25.0, lon: -125.0, score: 20}])
|
|
ScoresFile.write!(10_000, future, [%{lat: 25.0, lon: -125.0, score: 30}])
|
|
|
|
assert :ok = PropagationPruneWorker.perform(%Oban.Job{})
|
|
|
|
assert {:error, :enoent} = ScoresFile.read(10_000, old)
|
|
assert {:ok, _} = ScoresFile.read(10_000, fresh)
|
|
assert {:ok, _} = ScoresFile.read(10_000, future)
|
|
end
|
|
|
|
test "is a no-op when nothing is stale" do
|
|
now = DateTime.utc_now()
|
|
fresh = now |> DateTime.add(-30, :minute) |> DateTime.truncate(:second)
|
|
ScoresFile.write!(10_000, fresh, [%{lat: 25.0, lon: -125.0, score: 42}])
|
|
|
|
assert :ok = PropagationPruneWorker.perform(%Oban.Job{})
|
|
assert {:ok, _} = ScoresFile.read(10_000, fresh)
|
|
end
|
|
end
|
|
end
|