Skip to content

Commit

Permalink
Skip queueing next/prev link when there was none
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed Jul 1, 2024
1 parent 476ef8e commit b39a3bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/lib/orcasite/radio/workers/link_feed_stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ defmodule Orcasite.Radio.Workers.LinkFeedStream do
use Oban.Worker, queue: :feeds, unique: [keys: [:feed_stream_id], period: 10]

@impl Oban.Worker
def perform(%Oban.Job{args: %{"feed_stream_id" => nil} = args}) do
:ok
end

def perform(%Oban.Job{args: %{"feed_stream_id" => feed_stream_id} = args}) do
enqueue_prev_stream = Map.get(args, "enqueue_prev_stream", false)
enqueue_next_stream = Map.get(args, "enqueue_next_stream", false)
Expand All @@ -17,7 +21,8 @@ defmodule Orcasite.Radio.Workers.LinkFeedStream do
|> Ash.Changeset.for_update(:link_next_stream)
|> Orcasite.Radio.update()
|> case do
{:ok, %{next_feed_stream_id: next_feed_stream_id} = fs} ->
{:ok, %{next_feed_stream_id: next_feed_stream_id} = fs}
when not is_nil(next_feed_stream_id) ->
fs
|> Ash.Changeset.for_update(:update_end_time_and_duration)
|> Orcasite.Radio.update()
Expand All @@ -40,7 +45,7 @@ defmodule Orcasite.Radio.Workers.LinkFeedStream do
|> Ash.Changeset.for_update(:link_prev_stream)
|> Orcasite.Radio.update()
|> case do
{:ok, %{prev_feed_stream_id: prev_feed_stream_id}} ->
{:ok, %{prev_feed_stream_id: prev_feed_stream_id}} when not is_nil(prev_feed_stream_id) ->
# If new link to previous stream, queue another link job
if enqueue_prev_stream and prev_depth > 0 do
%{
Expand Down

0 comments on commit b39a3bc

Please sign in to comment.