From 3b004c1fad22df2839e2ee71eb4384491aeb7efd Mon Sep 17 00:00:00 2001 From: Skander Mzali Date: Mon, 1 Jul 2024 15:16:19 -0700 Subject: [PATCH] Only queue new jobs if there aren't currently available or executing --- server/lib/orcasite/radio/workers/link_feed_stream.ex | 8 +++++++- server/lib/orcasite/radio/workers/update_feed_segments.ex | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/lib/orcasite/radio/workers/link_feed_stream.ex b/server/lib/orcasite/radio/workers/link_feed_stream.ex index fdaa0ebc..ec1cf0e4 100644 --- a/server/lib/orcasite/radio/workers/link_feed_stream.ex +++ b/server/lib/orcasite/radio/workers/link_feed_stream.ex @@ -1,5 +1,11 @@ defmodule Orcasite.Radio.Workers.LinkFeedStream do - use Oban.Worker, queue: :feeds, unique: [keys: [:feed_stream_id], period: 10] + use Oban.Worker, + queue: :feeds, + unique: [ + keys: [:feed_stream_id], + period: :infinity, + states: [:available, :scheduled, :executing] + ] @impl Oban.Worker def perform(%Oban.Job{args: %{"feed_stream_id" => nil} = args}) do diff --git a/server/lib/orcasite/radio/workers/update_feed_segments.ex b/server/lib/orcasite/radio/workers/update_feed_segments.ex index 203b6a8b..49fb884a 100644 --- a/server/lib/orcasite/radio/workers/update_feed_segments.ex +++ b/server/lib/orcasite/radio/workers/update_feed_segments.ex @@ -1,5 +1,7 @@ defmodule Orcasite.Radio.Workers.UpdateFeedSegments do - use Oban.Worker, queue: :feeds, unique: [keys: [:feed_stream_id], period: 10] + use Oban.Worker, + queue: :feeds, + unique: [keys: [:feed_stream_id], period: :infinity, states: [:available, :scheduled, :executing]] @impl Oban.Worker def perform(%Oban.Job{args: %{"feed_stream_id" => feed_stream_id}}) do