fix(propagation): use map_size on grid_data telemetry count
The :score_band span was reading point_count via length(grid_data),
but grid_data is a %{{lat, lon} => profile} map. Every forecast-hour
job was crashing with ArgumentError before any scores landed, leaving
the map without current-hour forecasts. Swap to map_size/1.
This commit is contained in:
parent
543215864c
commit
0d022392fe
2 changed files with 19 additions and 2 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue