-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Episode delivery depends on status column * Update episode delivery flag * Incorporate the delivery flag into synced_with_apple? * Mark the episode as needing delivery * Add convenience method * Episode needs delivery to reach this * Annotate the episode publish logging methods * Extract the apple delivery status off the episode model * Include id in index, reset on mutate
- Loading branch information
Showing
11 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Apple | ||
class EpisodeDeliveryStatus < ApplicationRecord | ||
belongs_to :episode, class_name: "::Episode" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
db/migrate/20230920153421_add_needs_apple_delivery_to_episode.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class AddNeedsAppleDeliveryToEpisode < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :apple_episode_delivery_statuses do |t| | ||
t.references :episode, null: false, foreign_key: true | ||
t.boolean :delivered, default: false | ||
|
||
t.datetime :created_at, null: false | ||
end | ||
|
||
execute('CREATE INDEX "index_apple_episode_delivery_statuses_on_episode_id_created_at" ON "apple_episode_delivery_statuses" ("episode_id", "created_at") INCLUDE (delivered, id);') | ||
|
||
reversible do |dir| | ||
dir.up do | ||
episode_ids = SyncLog.where(feeder_type: :episodes).pluck(:feeder_id) | ||
apple_episodes = | ||
Episode.where(id: episode_ids).map do |e| | ||
Apple::Episode.new(show: true, feeder_episode: e, api: true) | ||
end | ||
|
||
needs_delivery_episodes = [] | ||
apple_episodes.each do |apple_episode| | ||
if (apple_episode.podcast_container.nil? || apple_episode.podcast_container.needs_delivery?) || apple_episode.apple_hosted_audio_asset_container_id.blank? | ||
apple_episode.feeder_episode.apple_needs_delivery! | ||
needs_delivery_episodes << apple_episode.feeder_episode | ||
else | ||
apple_episode.feeder_episode.apple_has_delivery! | ||
end | ||
end | ||
|
||
Rails.logger.info("Needs delivery count: #{needs_delivery_episodes.length}") | ||
needs_delivery_episodes.sort_by(&:podcast_id).each do |ep| | ||
Rails.logger.info("Needs delivery episode: #{ep.id} podcast: #{ep.podcast_id}") | ||
end | ||
end | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20230921203839_add_fetch_count_to_podcast_container.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddFetchCountToPodcastContainer < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :apple_podcast_containers, :source_fetch_count, :integer, default: 0, null: false | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters