Skip to content

Commit

Permalink
Use more descriptive names
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Jul 25, 2023
1 parent ef1f1e1 commit 67c7d70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/apple/episode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ def drafting?
apple_json&.dig("attributes", "publishingState") == "DRAFTING"
end

def apple_upload_complete?
feeder_episode.apple_podcast_container.skip_delivery?
def container_upload_complete?
feeder_episode.apple_podcast_container.container_upload_satisfied?
end

def audio_asset_vendor_id
Expand Down Expand Up @@ -437,7 +437,7 @@ def reset_for_upload!
end

def synced_with_apple?
audio_asset_state_success? && apple_upload_complete? && !drafting?
audio_asset_state_success? && container_upload_complete? && !drafting?
end

def waiting_for_asset_state?
Expand Down
4 changes: 4 additions & 0 deletions app/models/apple/podcast_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def delivery_settled?
end

def skip_delivery?
container_upload_satisfied?
end

def container_upload_satisfied?
# Sets us up for a retry if something prevented the audio from being
# marked as uploaded and then processed and validated. Assuming that we
# get to that point and the audio is still missing, we should be able to
Expand Down
2 changes: 1 addition & 1 deletion app/models/apple/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def mark_delivery_files_uploaded!(eps)

def publish_drafting!(eps)
Rails.logger.tagged("##{__method__}") do
eps = eps.select { |ep| ep.drafting? && ep.apple_upload_complete? }
eps = eps.select { |ep| ep.drafting? && ep.container_upload_complete? }

res = Apple::Episode.publish(api, show, eps)
Rails.logger.info("Published #{res.length} drafting episodes.")
Expand Down
2 changes: 1 addition & 1 deletion test/models/apple/publisher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

describe "#publish_drafting!" do
it "should call the episode publish drafting class method" do
ep = OpenStruct.new(drafting?: true, apple_upload_complete?: true)
ep = OpenStruct.new(drafting?: true, container_upload_complete?: true)
mock = Minitest::Mock.new
mock.expect(:call, [], [apple_publisher.api, apple_publisher.show, [ep]])

Expand Down

0 comments on commit 67c7d70

Please sign in to comment.