Prune HRRR grid profiles older than 48h after each scoring run
Deletes grid-aligned profiles (0.125 degree) older than 48 hours while preserving QSO-linked profiles at arbitrary positions. Called after each PropagationGridWorker run.
This commit is contained in:
parent
2da061201d
commit
6d103d7cc4
2 changed files with 29 additions and 0 deletions
|
|
@ -256,6 +256,33 @@ defmodule Microwaveprop.Weather do
|
|||
{Float.round(lat / 1.0, 2), Float.round(lon / 1.0, 2)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Delete HRRR grid profiles older than 48 hours that sit on the 0.125° grid.
|
||||
Preserves QSO-linked profiles which are at arbitrary lat/lon positions.
|
||||
"""
|
||||
def prune_old_grid_profiles do
|
||||
cutoff = DateTime.add(DateTime.utc_now(), -48, :hour)
|
||||
step = 0.125
|
||||
|
||||
{deleted, _} =
|
||||
Repo.delete_all(
|
||||
from(h in HrrrProfile,
|
||||
where:
|
||||
h.valid_time < ^cutoff and
|
||||
fragment("? = round(?::numeric / ? ) * ?", h.lat, h.lat, ^step, ^step) and
|
||||
fragment("? = round(?::numeric / ? ) * ?", h.lon, h.lon, ^step, ^step)
|
||||
)
|
||||
)
|
||||
|
||||
if deleted > 0 do
|
||||
require Logger
|
||||
|
||||
Logger.info("Pruned #{deleted} old HRRR grid profiles (keeping QSO profiles)")
|
||||
end
|
||||
|
||||
deleted
|
||||
end
|
||||
|
||||
def round_to_iemre_grid(lat, lon) do
|
||||
{Float.round(lat * 8) / 8, Float.round(lon * 8) / 8}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ defmodule Microwaveprop.Workers.PropagationGridWorker do
|
|||
Logger.info("PropagationGrid: resuming backfill queues")
|
||||
Enum.each(@pause_queues, &Oban.resume_queue(queue: &1))
|
||||
|
||||
Weather.prune_old_grid_profiles()
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue