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

Add data_hygiene:discard_drafts_and_unpublish #3081

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KludgeKML
Copy link
Contributor

@KludgeKML KludgeKML commented Jan 14, 2025

  • takes a content_id and unpublishes that with a 410 Gone, discarding drafts if necessary.
  • Immediate use is to unpublish robots.txt, which is now handled entirely within nginx, so has an unnecessary special route.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the publishing platform team. Please let us know in #govuk-publishing-platform when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

@KludgeKML KludgeKML requested a review from brucebolt January 14, 2025 11:22
@KludgeKML KludgeKML force-pushed the unpublish-robots-txt branch from 567f92d to 6d56124 Compare January 14, 2025 13:50
@KludgeKML KludgeKML changed the title Unpublish robots.txt Add data_hygiene:discard_drafts_and_unpublish Jan 14, 2025
- takes a content_id and unpublishes that with a 410 Gone, discarding
  drafts if necessary.
- Immediate use is to unpublish robots.txt, which is now handled entirely
  within nginx, so has an unnecessary special route.
@KludgeKML KludgeKML force-pushed the unpublish-robots-txt branch from 6d56124 to 1cda20f Compare January 14, 2025 13:52

desc "Discard drafts (if present) and unpublish"
task :discard_drafts_and_unpublish, %i[content_id] => :environment do |_, args|
document = Document.where(content_id: args[:content_id]).first
Copy link
Member

Choose a reason for hiding this comment

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

You could get multiple documents returned here, since the same content ID is used for multiple locales.

I'd recommend returning all of them, then looping through to discard the drafts and unpublish each one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does the unpublish work with locales? It's not clear to me how to pass a document object to Commands::V2::Unpublish (the examples I can find either pass in a content id, which obviously doesn't help, or an edition). Do I discard all the drafts and then pass in the Document's latest edition?

Copy link
Member

Choose a reason for hiding this comment

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

The discard and unpublish commands can both take a locale as an argument (example).

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