feat(status): show hrrr-point-rs queue in Rust workers panel

Second row in the Rust worker table pulls from hrrr_fetch_tasks so
per-QSO HRRR backfill progress is visible alongside prop-grid-rs.
Same columns (Running / Queued / Retrying / Done 1h), 2s cache, same
refresh debounce as the grid_tasks panel.
This commit is contained in:
Graham McIntire 2026-04-20 13:45:07 -05:00
parent 818b270a0a
commit f3fab3092c
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -25,6 +25,7 @@ defmodule MicrowavepropWeb.StatusLive do
unprocessed = count_unprocessed()
db_stats = fetch_db_stats()
grid_tasks = fetch_grid_tasks_stats()
hrrr_point_tasks = fetch_hrrr_point_tasks_stats()
{:ok,
assign(socket,
@ -33,6 +34,7 @@ defmodule MicrowavepropWeb.StatusLive do
unprocessed: unprocessed,
db_stats: db_stats,
grid_tasks: grid_tasks,
hrrr_point_tasks: hrrr_point_tasks,
refresh_timer: nil
)}
end
@ -57,6 +59,7 @@ defmodule MicrowavepropWeb.StatusLive do
unprocessed: count_unprocessed(),
db_stats: fetch_db_stats(),
grid_tasks: fetch_grid_tasks_stats(),
hrrr_point_tasks: fetch_hrrr_point_tasks_stats(),
refresh_timer: nil
)}
end
@ -224,6 +227,49 @@ defmodule MicrowavepropWeb.StatusLive do
}
end
defp fetch_hrrr_point_tasks_stats do
Cache.fetch_or_store({__MODULE__, :hrrr_point_tasks_stats}, 2_000, fn ->
fetch_hrrr_point_tasks_stats_raw()
end)
end
# Snapshot of the Rust hrrr-point-rs work queue (per-QSO HRRR batches,
# one row per valid_time). Same shape as grid_tasks_stats so the UI
# can render both in a single table.
defp fetch_hrrr_point_tasks_stats_raw do
running_count =
Repo.one(
from(t in "hrrr_fetch_tasks",
where: t.status == "running",
select: count(t.id)
)
)
counts_by_status =
from(t in "hrrr_fetch_tasks",
where: t.status in ["queued", "failed"],
group_by: t.status,
select: {t.status, count(t.id)}
)
|> Repo.all()
|> Map.new()
done_1h =
Repo.one(
from(t in "hrrr_fetch_tasks",
where: t.status == "done" and t.completed_at > ago(1, "hour"),
select: count(t.id)
)
)
%{
running: running_count,
queued: Map.get(counts_by_status, "queued", 0),
failed: Map.get(counts_by_status, "failed", 0),
done_1h: done_1h
}
end
defp fetch_stats do
Cache.fetch_or_store({__MODULE__, :stats}, 2_000, fn -> fetch_stats_raw() end)
end
@ -515,7 +561,7 @@ defmodule MicrowavepropWeb.StatusLive do
<div class="divider" />
<h2 class="text-base font-semibold mb-2">Rust Grid Worker (prop-grid-rs)</h2>
<h2 class="text-base font-semibold mb-2">Rust Workers</h2>
<div id="grid-tasks-panel" class="overflow-x-auto mb-4">
<table class="table table-sm">
<thead>
@ -557,6 +603,29 @@ defmodule MicrowavepropWeb.StatusLive do
</td>
<td>{format_number(@grid_tasks.done_1h)}</td>
</tr>
<tr>
<td class="font-semibold">hrrr-point-rs</td>
<td>
<%= if @hrrr_point_tasks.running == 0 do %>
0
<% else %>
<span class="flex items-center gap-2">
<span class="loading loading-spinner loading-xs"></span>
<span class="font-mono text-xs">{@hrrr_point_tasks.running}</span>
<span class="opacity-60 text-xs">batches</span>
</span>
<% end %>
</td>
<td>{format_number(@hrrr_point_tasks.queued)}</td>
<td>
<%= if @hrrr_point_tasks.failed > 0 do %>
<span class="text-warning">{@hrrr_point_tasks.failed}</span>
<% else %>
0
<% end %>
</td>
<td>{format_number(@hrrr_point_tasks.done_1h)}</td>
</tr>
</tbody>
</table>
</div>