Skip to content

Conversation

@svevang
Copy link
Member

@svevang svevang commented Nov 20, 2025

closes #1354

This PR improves how episode integration statuses are displayed in the UI, particularly for feeds using delegated delivery where not all episodes are published to external integrations. It also

  • Updates the Apple publishing flow to ensure that the publishing routine is nestled under the topmost delivery status. So if an episode is marked as delivered? then it is marked as published in Apple's system.
  • Ensures that feed inclusion is take into account when displaying status via integration_feed_episode?. This prevents showing misleading "processing" or "incomplete" statuses for episodes that will never be published to an integration.
  • Delegated delivery uses the same badges and view code as the other integrations and media (via media_statuses translations)

Copy link
Member

@kookster kookster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, esp all the tests.
There are a couple of places I suggested having another look - where Apple code seems to match generic integration code and maybe can be consolidated, and a place where a generic integration method now has apple specific logic?

"complete"
else
"not_found"
"complete"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing to a default of complete? I guess I worry that could show complete even when it is not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking both possibilities for delivered? boolean means that the else branch was unreachable code:

elsif !status.delivered?
"processing"
elsif status.delivered?
"complete"

Hence the rearrangement of the apple episode publishing invocation in this PR https://github.com/PRX/feeder.prx.org/pull/1384/files#diff-a2b7e8c0371fceca58ba0b83a4db37ef232d2770af6aeb616aaac0e3b0259876R148. Sort of a subtle difference, but I think makes sense to see delivered episodes as being "complete" here (already published).

def integration_error_state?(integration)
case integration
when :apple
apple_episode&.audio_asset_state_error? || apple_episode&.delivery_file_errors?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this concern is generic to any integration, could we have this call a generic method that could be implemented by any of the integrations, and then have that implemented for apple with this check, and in megaphone (or in a default episode) just return false?

Probably we should also introduce a more generic error status on the episode delivery status record, like if the latest update returned a 50x we could set that and show we're getting errors back from the integration API calls? That seems like a different issue/PR - right now I think an error back from Megaphone would show up as an incomplete or processing state, assuming it would be retried

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have this call a generic method that could be implemented by any of the integrations

Yep. I'm in a functional mindset where I wanted to see the complete projection of state on the branches, but def this is not good OOP style. Will extract this into helpers!

we should also introduce a more generic error status on the episode delivery status record

Yep, also thinking about state, and that discussion we had earlier about stale / drifted state on the sync on the episode publishing status (related to API errors).

@svevang svevang requested a review from kookster November 21, 2025 19:39
Copy link
Member

@kookster kookster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks even better!

end

def integration_episode(integration)
integration_episode_method = "#{integration}_episode"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good idea

apple_episode&.audio_asset_state_error? || apple_episode&.delivery_file_errors?
integration_episode_method = "#{integration}_episode"
if respond_to?(integration_episode_method)
send(integration_episode_method)&.error_state? || false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clean, thank you!

include TextSanitizer
include EmbedPlayerHelper
include AppleDelivery
include AppleIntegration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a better name I think

<%= local_time_ago(episode_integration_updated_at(integration, episode)) %>
</p>
</div>
<% end %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delegated delivery UI missing episode state

3 participants