Skip to content

Commit

Permalink
Merge pull request #1835 from alphagov/licence-finder-archive
Browse files Browse the repository at this point in the history
Add task to unpublish licence finder
  • Loading branch information
KludgeKML authored Jul 13, 2023
2 parents d80eded + 351eeb0 commit 8976d94
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/tasks/once_off/unpublish_licence_finder.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace :once_off do
desc "Archives and unpublishes the licence finder, redirecting to the new one"
task unpublish_licence_finder: :environment do
licence_finder_edition = Edition.where(state: "published", slug: "licence-finder").last
artefact = licence_finder_edition.artefact
redirect_url = "/find-licences"

artefact.assign_attributes(state: "archived", redirect_url:)
artefact.save_as_task!("once_off:unpublish_licence_finder")

Services.publishing_api.unpublish(
artefact.content_id,
locale: artefact.language,
type: "redirect",
redirects: [
{
path: "/#{artefact.slug}",
type: "prefix",
destination: redirect_url,
segments_mode: "ignore",
},
],
discard_drafts: true,
)
puts("#{licence_finder_edition.slug} archived, unpublished with redirect to #{redirect_url}")
end
end

0 comments on commit 8976d94

Please sign in to comment.