Disable auto HRRR backfill on contact detail page view

This commit is contained in:
Graham McIntire 2026-04-01 13:57:23 -05:00
parent 71091219f4
commit f02b111c1f
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -9,8 +9,8 @@ defmodule MicrowavepropWeb.ContactLive.Show do
alias Microwaveprop.Terrain.ElevationClient
alias Microwaveprop.Terrain.TerrainAnalysis
alias Microwaveprop.Weather
alias Microwaveprop.Weather.HrrrClient
alias Microwaveprop.Workers.HrrrFetchWorker
# alias Microwaveprop.Weather.HrrrClient
# alias Microwaveprop.Workers.HrrrFetchWorker
@earth_radius_m 6_371_000.0
@ -175,35 +175,34 @@ defmodule MicrowavepropWeb.ContactLive.Show do
defp maybe_enqueue_hrrr(hrrr, _contact) when not is_nil(hrrr), do: {hrrr, :loaded}
defp maybe_enqueue_hrrr(nil, contact) do
lat = contact.pos1 && contact.pos1["lat"]
lon = contact.pos1 && (contact.pos1["lon"] || contact.pos1["lng"])
# TODO: Re-enable auto HRRR backfill on page view when appropriate
# defp maybe_enqueue_hrrr(nil, contact) do
# lat = contact.pos1 && contact.pos1["lat"]
# lon = contact.pos1 && (contact.pos1["lon"] || contact.pos1["lng"])
#
# if lat && lon && hrrr_likely_available?(contact.qso_timestamp) do
# valid_time = HrrrClient.nearest_hrrr_hour(contact.qso_timestamp)
# {rlat, rlon} = Weather.round_to_hrrr_grid(lat, lon)
#
# Oban.insert(
# HrrrFetchWorker.new(%{
# "lat" => rlat,
# "lon" => rlon,
# "valid_time" => DateTime.to_iso8601(valid_time)
# })
# )
#
# {nil, :queued}
# else
# {nil, :unavailable}
# end
# end
defp maybe_enqueue_hrrr(nil, _contact), do: {nil, :unavailable}
if lat && lon && hrrr_likely_available?(contact.qso_timestamp) do
valid_time = HrrrClient.nearest_hrrr_hour(contact.qso_timestamp)
{rlat, rlon} = Weather.round_to_hrrr_grid(lat, lon)
Oban.insert(
HrrrFetchWorker.new(%{
"lat" => rlat,
"lon" => rlon,
"valid_time" => DateTime.to_iso8601(valid_time)
})
)
{nil, :queued}
else
{nil, :unavailable}
end
end
# HRRR data is only available from ~2016 onward and kept for ~2 days on NOAA S3.
# Historical re-analysis archives go back further but the worker only fetches from the live feed.
# For contacts older than 48 hours, HRRR GRIB2 files are no longer on S3.
defp hrrr_likely_available?(timestamp) do
hours_ago = DateTime.diff(DateTime.utc_now(), timestamp, :hour)
hours_ago < 48
end
# defp hrrr_likely_available?(timestamp) do
# hours_ago = DateTime.diff(DateTime.utc_now(), timestamp, :hour)
# hours_ago < 48
# end
defp load_solar(contact) do
contact.qso_timestamp