Fix enrichment: check actual data presence, not just status flag
This commit is contained in:
parent
f897a9a321
commit
15a09f0d7b
1 changed files with 22 additions and 20 deletions
|
|
@ -183,26 +183,27 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
end
|
||||
|
||||
defp maybe_enqueue_weather(weather, contact) do
|
||||
if contact.weather_status == :complete do
|
||||
contact
|
||||
else
|
||||
has_data = weather.surface_observations != [] or weather.soundings != []
|
||||
has_data = weather.surface_observations != [] or weather.soundings != []
|
||||
|
||||
cond do
|
||||
has_data ->
|
||||
cond do
|
||||
has_data ->
|
||||
if contact.weather_status != :complete do
|
||||
Radio.set_enrichment_status!([contact.id], :weather_status, :complete)
|
||||
%{contact | weather_status: :complete}
|
||||
end
|
||||
|
||||
contact.pos1 && contact.weather_status in [:pending, :failed, :queued] ->
|
||||
jobs = ContactWeatherEnqueueWorker.build_weather_jobs([contact])
|
||||
if jobs != [], do: Oban.insert_all(jobs)
|
||||
Radio.set_enrichment_status!([contact.id], :weather_status, :queued)
|
||||
%{contact | weather_status: :queued}
|
||||
%{contact | weather_status: :complete}
|
||||
|
||||
true ->
|
||||
Radio.set_enrichment_status!([contact.id], :weather_status, :unavailable)
|
||||
%{contact | weather_status: :unavailable}
|
||||
end
|
||||
contact.pos1 && contact.weather_status not in [:queued, :unavailable] ->
|
||||
jobs = ContactWeatherEnqueueWorker.build_weather_jobs([contact])
|
||||
if jobs != [], do: Oban.insert_all(jobs)
|
||||
Radio.set_enrichment_status!([contact.id], :weather_status, :queued)
|
||||
%{contact | weather_status: :queued}
|
||||
|
||||
is_nil(contact.pos1) ->
|
||||
%{contact | weather_status: :unavailable}
|
||||
|
||||
true ->
|
||||
contact
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -299,10 +300,11 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
end
|
||||
end
|
||||
|
||||
defp maybe_enqueue_hrrr(hrrr, %{hrrr_status: :complete} = contact), do: {hrrr, contact, 0}
|
||||
|
||||
defp maybe_enqueue_hrrr(hrrr, contact) when not is_nil(hrrr) do
|
||||
Radio.set_enrichment_status!([contact.id], :hrrr_status, :complete)
|
||||
if contact.hrrr_status != :complete do
|
||||
Radio.set_enrichment_status!([contact.id], :hrrr_status, :complete)
|
||||
end
|
||||
|
||||
{hrrr, %{contact | hrrr_status: :complete}, 0}
|
||||
end
|
||||
|
||||
|
|
@ -310,7 +312,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
lat = contact.pos1 && contact.pos1["lat"]
|
||||
lon = contact.pos1 && (contact.pos1["lon"] || contact.pos1["lng"])
|
||||
|
||||
if lat && lon && contact.hrrr_status in [:pending, :failed, :queued] do
|
||||
if lat && lon && contact.hrrr_status not in [:queued, :unavailable] do
|
||||
valid_time = HrrrClient.nearest_hrrr_hour(contact.qso_timestamp)
|
||||
{rlat, rlon} = Weather.round_to_hrrr_grid(lat, lon)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue