Fix HRRR prune timeout: bound time range for partition pruning

This commit is contained in:
Graham McIntire 2026-04-01 15:27:11 -05:00
parent bf90249a06
commit 239bf707aa
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -263,6 +263,9 @@ defmodule Microwaveprop.Weather do
"""
def prune_old_grid_profiles do
cutoff = DateTime.add(DateTime.utc_now(), -24, :hour)
# Bound the scan to recent partitions only (grid profiles are at most ~48h old).
# Without a lower bound, Postgres scans every partition back to 2016.
floor = DateTime.add(DateTime.utc_now(), -72, :hour)
# Only delete profiles on the 0.125° propagation grid, preserving QSO-linked
# profiles which sit at arbitrary lat/lon positions (HRRR's native ~3km grid).
@ -270,12 +273,12 @@ defmodule Microwaveprop.Weather do
Repo.query!(
"""
DELETE FROM hrrr_profiles
WHERE valid_time < $1
WHERE valid_time >= $2 AND valid_time < $1
AND (lat * 1000)::int % 125 = 0
AND (lon * 1000)::int % 125 = 0
""",
[cutoff],
timeout: 120_000
[cutoff, floor],
timeout: 300_000
)
if deleted > 0 do