- Radio context with QSO schema and CSV import script (58K contacts) - Solar index schema, GFZ client, and daily Oban cron worker - LiveView dashboard with QSO table and weather correlation views - Parallelize weather import script using Task.async_stream (10 concurrent workers) - Replace sequential rate_limit sleeps with concurrency-based backpressure - Atomic progress counter for interleave-safe reporting
24 lines
571 B
Elixir
24 lines
571 B
Elixir
defmodule Microwaveprop.Workers.SolarIndexWorker do
|
|
@moduledoc false
|
|
use Oban.Worker, queue: :solar, max_attempts: 3
|
|
|
|
alias Microwaveprop.Weather
|
|
alias Microwaveprop.Weather.SolarClient
|
|
|
|
@impl Oban.Worker
|
|
def perform(%Oban.Job{}) do
|
|
since_date = Date.add(Date.utc_today(), -7)
|
|
|
|
case SolarClient.fetch_solar_indices() do
|
|
{:ok, all_records} ->
|
|
all_records
|
|
|> SolarClient.filter_since(since_date)
|
|
|> Enum.each(&Weather.upsert_solar_index/1)
|
|
|
|
:ok
|
|
|
|
{:error, reason} ->
|
|
{:error, reason}
|
|
end
|
|
end
|
|
end
|