Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Republish drafts of other translations on PUT of new translation #2769

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

brucebolt
Copy link
Member

When a draft translation is added and another translation of the same content ID exists, we need to send the existing translation(s) downstream so their available_translations links can be updated to include the new translation.

We're not currently doing this, which leads to a situation where the link to the new translation never appears on the draft of the existing translations.

Trello card

@brucebolt brucebolt marked this pull request as ready for review June 12, 2024 15:57
Copy link
Contributor

@Gweaton Gweaton left a comment

Choose a reason for hiding this comment

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

I think this makes sense, just have a couple of qs/comments

@@ -200,6 +202,29 @@ def clear_draft_item_of_different_locale_but_matching_base_path
)
end

def update_draft_items_of_different_locale_but_matching_content_id
return unless payload[:base_path]
return if Document.where(content_id: payload[:content_id], locale: payload[:locale]).any?
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding a couple of tests for these early returns? Might also help serve as documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's a good idea, I'll add them.

.map(&:draft)
.compact

after_transaction_commit do
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the transaction here? Is it that the rest of the call method executes successfully and we only want to run this if it does? Or is it scoped to this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's after the call (I think it's this line that executes the block), so we only send the payload to content store once the data has actually been committed to the database.

When a draft translation is added and another translation of the same
content ID exists, we need to send the existing translation(s)
downstream so their `available_translations` links can be updated to
include the new translation.

We're not currently doing this, which leads to a situation where the
link to the new translation never appears on the draft of the existing
translations.
@brucebolt brucebolt force-pushed the republish-translation-put branch from c801987 to d3c4199 Compare June 13, 2024 12:07
@brucebolt brucebolt merged commit 81c17f5 into main Jun 20, 2024
12 checks passed
@brucebolt brucebolt deleted the republish-translation-put branch June 20, 2024 07:04
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.

2 participants