diff --git a/lib/microwaveprop/workers/propagation_grid_worker.ex b/lib/microwaveprop/workers/propagation_grid_worker.ex index be372347..2b733426 100644 --- a/lib/microwaveprop/workers/propagation_grid_worker.ex +++ b/lib/microwaveprop/workers/propagation_grid_worker.ex @@ -375,10 +375,12 @@ defmodule Microwaveprop.Workers.PropagationGridWorker do compute_scores_algorithm(grid_data, valid_time, forecast_hour == 0) end - defp compute_scores_algorithm(grid_data, valid_time, include_factors?) do + @doc false + # Public for testing. grid_data is a %{{lat, lon} => profile} map. + def compute_scores_algorithm(grid_data, valid_time, include_factors?) do Microwaveprop.Instrument.span( [:propagation_grid, :score_band], - %{point_count: length(grid_data)}, + %{point_count: map_size(grid_data)}, fn -> grid_data |> Task.async_stream( diff --git a/test/microwaveprop/workers/propagation_grid_worker_test.exs b/test/microwaveprop/workers/propagation_grid_worker_test.exs index 7286f82b..0a2febb4 100644 --- a/test/microwaveprop/workers/propagation_grid_worker_test.exs +++ b/test/microwaveprop/workers/propagation_grid_worker_test.exs @@ -29,6 +29,21 @@ defmodule Microwaveprop.Workers.PropagationGridWorkerTest do end end + describe "compute_scores_algorithm/3" do + test "accepts a map of {{lat, lon} => profile} without raising" do + # grid_data is a map keyed by {lat, lon}, not a list. + # A regression guard against using length/1 on the map. + valid_time = ~U[2026-04-19 15:00:00Z] + + assert [] = + PropagationGridWorker.compute_scores_algorithm( + %{}, + valid_time, + false + ) + end + end + describe "perform/1 — chain seeding (empty args)" do test "enqueues all 19 forecast-hour jobs at once, all pointing at the same run_time" do Oban.Testing.with_testing_mode(:manual, fn ->