-
Notifications
You must be signed in to change notification settings - Fork 6
/
publishing_api.rake
68 lines (55 loc) · 2.14 KB
/
publishing_api.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require_relative "../publish_organisations_api_route"
require_relative "../special_route_publisher"
namespace :publishing_api do
desc "Send all tags to the publishing-api, skipping any marked as dirty"
task send_all_tags: :environment do
TagRepublisher.new.republish_tags(Tag.all)
RedirectPublisher.new.republish_redirects
end
desc "Send all published tags to the publishing-api, skipping any marked as dirty"
task send_published_tags: :environment do
TagRepublisher.new.republish_tags(Tag.published)
end
desc "Publish the /api/organisations prefix route"
task publish_organisations_api_route: :environment do
PublishOrganisationsApiRoute.new.publish
end
desc "Publish all special routes"
task publish_special_routes: :environment do
publisher = SpecialRoutePublisher.new
SpecialRoutePublisher.routes.each do |route|
publisher.publish(route)
end
end
desc "Unpublish all special routes as GONE. Please consider redirecting instead."
task unpublish_special_routes: :environment do
publisher = SpecialRoutePublisher.new
SpecialRoutePublisher.routes.each do |route|
options = {
type: "gone",
}
publisher.unpublish(route[:content_id], options)
end
end
desc "Publish special route using its base path. It must already be defined in lib/special_route_publisher.rb"
task :publish_special_route, [:base_path] => :environment do |_task, args|
route = SpecialRoutePublisher.find_route(args.base_path)
SpecialRoutePublisher.new.publish(route)
end
desc "Patch links for Mainstream Browse Pages"
task patch_links_for_mainstream_browse_pages: :environment do
MainstreamBrowsePage.all.find_each do |page|
Services.publishing_api.patch_links(
page.content_id,
MainstreamBrowsePagePresenter.new(page).render_links_for_publishing_api,
)
puts "Patching links for #{page.content_id}..."
end
root_page = RootBrowsePagePresenter.new("state" => "published")
Services.publishing_api.patch_links(
root_page.content_id,
root_page.render_links_for_publishing_api,
)
puts "Links patched for root page..."
end
end