Fix HRRR prune timeout: bound time range for partition pruning
This commit is contained in:
parent
bf90249a06
commit
239bf707aa
1 changed files with 6 additions and 3 deletions
|
|
@ -263,6 +263,9 @@ defmodule Microwaveprop.Weather do
|
||||||
"""
|
"""
|
||||||
def prune_old_grid_profiles do
|
def prune_old_grid_profiles do
|
||||||
cutoff = DateTime.add(DateTime.utc_now(), -24, :hour)
|
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
|
# 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).
|
# profiles which sit at arbitrary lat/lon positions (HRRR's native ~3km grid).
|
||||||
|
|
@ -270,12 +273,12 @@ defmodule Microwaveprop.Weather do
|
||||||
Repo.query!(
|
Repo.query!(
|
||||||
"""
|
"""
|
||||||
DELETE FROM hrrr_profiles
|
DELETE FROM hrrr_profiles
|
||||||
WHERE valid_time < $1
|
WHERE valid_time >= $2 AND valid_time < $1
|
||||||
AND (lat * 1000)::int % 125 = 0
|
AND (lat * 1000)::int % 125 = 0
|
||||||
AND (lon * 1000)::int % 125 = 0
|
AND (lon * 1000)::int % 125 = 0
|
||||||
""",
|
""",
|
||||||
[cutoff],
|
[cutoff, floor],
|
||||||
timeout: 120_000
|
timeout: 300_000
|
||||||
)
|
)
|
||||||
|
|
||||||
if deleted > 0 do
|
if deleted > 0 do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue