-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove usages and functionality to load finder by filename
To make functionality consistent across publishing and unpublishing, and using slug to load the schema for ease of running support tasks, there is no longer a need to load a finder schema by filename.
- Loading branch information
Showing
6 changed files
with
44 additions
and
86 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
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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
require "services" | ||
|
||
namespace :unpublish do | ||
desc "Unpublish a Finder by file name and redirect the finder page to specific URL" | ||
task :redirect_finder, %i[finder_file redirect_url] => :environment do |_, args| | ||
desc "Unpublish a Finder by slug and redirect the finder page to specific URL" | ||
task :redirect_finder, %i[slug redirect_url] => :environment do |_, args| | ||
require "finder_loader" | ||
|
||
schema = FinderLoader.new.finder(args.finder_file).first[:file] | ||
schema = FinderLoader.new.finder_by_slug(args.slug)[:file] | ||
puts "=== Finder found ===" | ||
puts "Slug: #{schema['base_path']}" | ||
puts "Finder name: #{schema['name']}" | ||
puts "Content ID: #{schema['content_id']}" | ||
puts "Redirecting to: #{args.redirect_url}" | ||
|
||
begin | ||
response = GdsApi.publishing_api.unpublish( | ||
schema["content_id"], | ||
type: "redirect", | ||
alternative_path: args.redirect_url, | ||
discard_drafts: true, | ||
) | ||
puts "Publishing API response #{response.code}: #{response.raw_response_body}" | ||
puts "Finder unpublished" | ||
rescue GdsApi::HTTPServerError => e | ||
puts "Error unpublishing finder: #{e.inspect}" | ||
end | ||
response = GdsApi.publishing_api.unpublish( | ||
schema["content_id"], | ||
type: "redirect", | ||
alternative_path: args.redirect_url, | ||
discard_drafts: true, | ||
) | ||
puts "Publishing API response #{response.code}: #{response.raw_response_body}" | ||
puts "Finder unpublished" | ||
rescue GdsApi::HTTPServerError => e | ||
puts "Error unpublishing finder: #{e.inspect}" | ||
rescue StandardError => e | ||
puts "Error: #{e.inspect}" | ||
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