Fix unique constraint blocking re-enqueues of completed jobs

- Only deduplicate against active jobs (available/scheduled/executing/
  retryable), not completed ones. Completed jobs no longer block new
  inserts for the same args.
- Period reduced from 3600s to 300s
- Fixes contacts stuck in :queued with no actual Oban jobs
This commit is contained in:
Graham McIntire 2026-04-02 16:34:39 -05:00
parent a8920e9480
commit 68fdd1d2b6
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
4 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
defmodule Microwaveprop.Workers.HrrrFetchWorker do
@moduledoc false
use Oban.Worker, queue: :hrrr, max_attempts: 20, unique: [period: 3600]
use Oban.Worker, queue: :hrrr, max_attempts: 20, unique: [period: 300, states: [:available, :scheduled, :executing, :retryable]]
alias Microwaveprop.Weather
alias Microwaveprop.Weather.HrrrClient

View file

@ -1,6 +1,6 @@
defmodule Microwaveprop.Workers.SolarIndexWorker do
@moduledoc false
use Oban.Worker, queue: :solar, max_attempts: 3, unique: [period: 3600]
use Oban.Worker, queue: :solar, max_attempts: 3, unique: [period: 300, states: [:available, :scheduled, :executing, :retryable]]
alias Microwaveprop.Weather
alias Microwaveprop.Weather.SolarClient

View file

@ -1,6 +1,6 @@
defmodule Microwaveprop.Workers.TerrainProfileWorker do
@moduledoc false
use Oban.Worker, queue: :terrain, max_attempts: 20, unique: [period: 3600]
use Oban.Worker, queue: :terrain, max_attempts: 20, unique: [period: 300, states: [:available, :scheduled, :executing, :retryable]]
alias Microwaveprop.Radio
alias Microwaveprop.Terrain

View file

@ -1,6 +1,6 @@
defmodule Microwaveprop.Workers.WeatherFetchWorker do
@moduledoc false
use Oban.Worker, queue: :weather, max_attempts: 20, unique: [period: 3600]
use Oban.Worker, queue: :weather, max_attempts: 20, unique: [period: 300, states: [:available, :scheduled, :executing, :retryable]]
alias Microwaveprop.Repo
alias Microwaveprop.Weather