Skip to content

Commit

Permalink
Only check queue_items with non-null states
Browse files Browse the repository at this point in the history
  • Loading branch information
cavis committed Feb 13, 2024
1 parent 90823d2 commit 74d277c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/release_episodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions test/models/concerns/release_episodes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 74d277c

Please sign in to comment.