From 715633bd1a49b1221a799fb92d72ad1b433dac09 Mon Sep 17 00:00:00 2001 From: syed-ali-tw Date: Fri, 12 Jul 2024 11:28:56 +0100 Subject: [PATCH] Add rake task to create popular links and links to homepage --- ...te_popular_links_and_link_to_homepage.rake | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/tasks/create_popular_links_and_link_to_homepage.rake diff --git a/lib/tasks/create_popular_links_and_link_to_homepage.rake b/lib/tasks/create_popular_links_and_link_to_homepage.rake new file mode 100644 index 000000000..40c56837f --- /dev/null +++ b/lib/tasks/create_popular_links_and_link_to_homepage.rake @@ -0,0 +1,22 @@ +desc "Create popular links and links to homepage" +task create_popular_links_and_link_to_homepage: [:environment] do + homepage_content_id = "f3bbdec2-0e62-4520-a7fd-6ffd5d36e03a".freeze + popular_links = PopularLinksEdition.new(title: "Homepage popular links", + link_items: [{ url: "url1.com", title: "title1" }, + { url: "url2.com", title: "title2" }, + { url: "url3.com", title: "title3" }, + { url: "url4.com", title: "title4" }, + { url: "url5.com", title: "title5" }, + { url: "url6.com", title: "title6" }]) + + popular_links.save! + + Services.publishing_api.patch_links( + homepage_content_id, + links: { + "popular_links" => [popular_links.content_id], + }, + ) +rescue StandardError => e + puts "Encountered error #{e.message}" +end