From 74d277cf436199113fa6d5d8a10b5f9f27bdb20a Mon Sep 17 00:00:00 2001 From: cavis Date: Tue, 13 Feb 2024 16:48:50 -0700 Subject: [PATCH] Only check queue_items with non-null states --- app/models/concerns/release_episodes.rb | 1 + test/models/concerns/release_episodes_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/release_episodes.rb b/app/models/concerns/release_episodes.rb index 4c7903f05..7bc749b93 100644 --- a/app/models/concerns/release_episodes.rb +++ b/app/models/concerns/release_episodes.rb @@ -25,6 +25,7 @@ module ReleaseEpisodes LATEST_QUEUE_TIMES = <<-SQL.squish SELECT podcast_id, MAX(created_at) AS latest_queue_time FROM publishing_queue_items + WHERE last_pipeline_state IS NOT NULL GROUP BY podcast_id SQL diff --git a/test/models/concerns/release_episodes_test.rb b/test/models/concerns/release_episodes_test.rb index a49991bdd..156d2a7bb 100644 --- a/test/models/concerns/release_episodes_test.rb +++ b/test/models/concerns/release_episodes_test.rb @@ -15,12 +15,12 @@ class ReleaseEpisodesTest < ActiveSupport::TestCase assert_equal [podcast], Podcast.to_release # queue item < published_at - still needs release - PublishingQueueItem.create!(podcast: podcast, created_at: 1.hour.ago) + PublishingQueueItem.create!(podcast: podcast, last_pipeline_state: "started", created_at: 1.hour.ago) assert_equal [episode], Episode.to_release assert_equal [podcast], Podcast.to_release # queue item > published_at - we're good! - PublishingQueueItem.create!(podcast: podcast, created_at: 1.minute.from_now) + PublishingQueueItem.create!(podcast: podcast, last_pipeline_state: "started", created_at: 1.minute.from_now) assert_empty Episode.to_release assert_empty Podcast.to_release end @@ -35,7 +35,7 @@ class ReleaseEpisodesTest < ActiveSupport::TestCase assert_equal [podcast], Podcast.to_release # add a queue item, and we're good - PublishingQueueItem.create!(podcast: podcast) + PublishingQueueItem.create!(podcast: podcast, last_pipeline_state: "started") assert_empty Episode.to_release assert_empty Podcast.to_release end @@ -54,7 +54,7 @@ class ReleaseEpisodesTest < ActiveSupport::TestCase assert_equal [podcast], Podcast.to_release # add a queue item, and we're good - PublishingQueueItem.create!(podcast: podcast) + PublishingQueueItem.create!(podcast: podcast, last_pipeline_state: "started") assert_empty Episode.to_release assert_empty Podcast.to_release end