Skip to content

Commit

Permalink
Clarify that the default is used in both places
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Oct 17, 2024
1 parent ccc9c62 commit e190272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/apple/episode_delivery_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ class EpisodeDeliveryStatus < ApplicationRecord
belongs_to :episode, -> { with_deleted }, class_name: "::Episode"

def self.update_status(episode, attrs)
new_status = (episode.apple_episode_delivery_status&.dup || new(episode: episode))
new_status = (episode.apple_episode_delivery_status&.dup || default_status(episode))
new_status.assign_attributes(attrs)
new_status.save!
episode.apple_episode_delivery_statuses.reset
new_status
end

def self.default_status(episode)
new(episode: episode)
end

def increment_asset_wait
self.class.update_status(episode, asset_processing_attempts: (asset_processing_attempts || 0) + 1)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/apple_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def apple_update_delivery_status(attrs)
end

def build_initial_delivery_status
Apple::EpisodeDeliveryStatus.new(episode: self)
Apple::EpisodeDeliveryStatus.default_status(self)
end

def apple_episode_delivery_status
Expand Down

0 comments on commit e190272

Please sign in to comment.