Ensure stale scores get pruned even when HRRR fetch fails
This commit is contained in:
parent
4bf9d0b4b0
commit
b7fc195e82
1 changed files with 26 additions and 24 deletions
|
|
@ -35,37 +35,39 @@ defmodule Microwaveprop.Workers.PropagationGridWorker do
|
|||
|
||||
Enum.each(@pause_queues, &Oban.pause_queue(queue: &1))
|
||||
|
||||
for_result =
|
||||
for fh <- 0..@max_forecast_hour do
|
||||
valid_time = DateTime.add(run_time, fh * 3600, :second)
|
||||
result = process_forecast_hour(points, run_time, fh, valid_time)
|
||||
try do
|
||||
for_result =
|
||||
for fh <- 0..@max_forecast_hour do
|
||||
valid_time = DateTime.add(run_time, fh * 3600, :second)
|
||||
result = process_forecast_hour(points, run_time, fh, valid_time)
|
||||
|
||||
case result do
|
||||
:ok -> valid_time
|
||||
_ -> nil
|
||||
case result do
|
||||
:ok -> valid_time
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
valid_times = Enum.reject(for_result, &is_nil/1)
|
||||
|
||||
if valid_times != [] do
|
||||
Phoenix.PubSub.broadcast(
|
||||
Microwaveprop.PubSub,
|
||||
"propagation:updated",
|
||||
{:propagation_updated, valid_times}
|
||||
)
|
||||
end
|
||||
|
||||
valid_times = Enum.reject(for_result, &is_nil/1)
|
||||
total_ms = System.monotonic_time(:millisecond) - t_start
|
||||
Logger.info("PropagationGrid: total time #{format_duration(total_ms)} (#{length(valid_times)} forecast hours)")
|
||||
|
||||
Logger.info("PropagationGrid: resuming backfill queues")
|
||||
Enum.each(@pause_queues, &Oban.resume_queue(queue: &1))
|
||||
:ok
|
||||
after
|
||||
Logger.info("PropagationGrid: resuming backfill queues")
|
||||
Enum.each(@pause_queues, &Oban.resume_queue(queue: &1))
|
||||
|
||||
Weather.prune_old_grid_profiles()
|
||||
Propagation.prune_old_scores()
|
||||
|
||||
if valid_times != [] do
|
||||
Phoenix.PubSub.broadcast(
|
||||
Microwaveprop.PubSub,
|
||||
"propagation:updated",
|
||||
{:propagation_updated, valid_times}
|
||||
)
|
||||
Weather.prune_old_grid_profiles()
|
||||
Propagation.prune_old_scores()
|
||||
end
|
||||
|
||||
total_ms = System.monotonic_time(:millisecond) - t_start
|
||||
Logger.info("PropagationGrid: total time #{format_duration(total_ms)} (#{length(valid_times)} forecast hours)")
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp process_forecast_hour(points, run_time, forecast_hour, valid_time) do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue