Some checks failed
Build and Push / Build and Push Docker Image (push) Has been cancelled
Create shared ContactsFixtures module with globally-unique qso_timestamp seconds to prevent unique-constraint violations when async test modules run in parallel and insert contacts with identical dedup-key columns. The qso_timestamp column is timestamp(0), so microsecond offsets were truncated — use System.unique_integer monotonic seconds instead. Also make count-asserting tests resilient to sandbox-leaked contacts from prior tests by using >= assertions or status-based checks rather than exact counts. Includes automated DateTime.add → DateTime.shift migration from mix format.
28 lines
912 B
Elixir
28 lines
912 B
Elixir
defmodule Microwaveprop.Workers.GridCachePruneWorker do
|
|
@moduledoc """
|
|
Prunes stale rows from the node-local `Microwaveprop.Weather.GridCache` ETS
|
|
table. Without this cron the cache grew unbounded: every hourly
|
|
`PropagationGridWorker` run plus peer `broadcast_put` added an entry per
|
|
forecast hour (~92k points * 19 hours), so long-lived pods eventually OOM'd.
|
|
|
|
Runs on the shared `:propagation` queue alongside `PropagationPruneWorker`
|
|
at a lower priority so the hourly grid chain never waits behind it.
|
|
"""
|
|
|
|
use Oban.Pro.Worker,
|
|
queue: :propagation,
|
|
priority: 5,
|
|
max_attempts: 3,
|
|
unique: [period: 300, states: :incomplete]
|
|
|
|
alias Microwaveprop.Weather.GridCache
|
|
|
|
@cutoff_hours 3
|
|
|
|
@impl Oban.Pro.Worker
|
|
def process(%Oban.Job{}) do
|
|
cutoff = DateTime.shift(DateTime.utc_now(), hour: -@cutoff_hours)
|
|
_removed = GridCache.prune_older_than(cutoff)
|
|
:ok
|
|
end
|
|
end
|