From c38f329ac252585ec843ab2022ce807f42ec84ae Mon Sep 17 00:00:00 2001 From: Richard Towers Date: Thu, 7 Dec 2023 16:51:10 +0000 Subject: [PATCH] Remove suggested_ordered_related_items Now that the [related links recommender](https://github.com/alphagov/govuk-related-links-recommender) is no longer running, suggested_ordered_related_items will be growing increasingly stale. I'm not sure whether publishing-api is even clever enough to keep suggested_ordered_related_items links somewhat up to date (e.g. if one is withdrawn, unpublished, or if a slug is changed) - it doesn't look like it from [a cursory glance at the code](https://github.com/alphagov/publishing-api/blob/main/lib/expansion_rules.rb). Note that there are around 164,000 published editions with suggested_ordered_related_items and only around 2,500 published editions with ordered_related_items, so this will have the effect of removing the related links sidebar from the majority of pages on GOV.UK (around 161,000 of them). --- app/controllers/content_items_controller.rb | 4 +--- test/controllers/content_items_controller_test.rb | 10 ---------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index 53b26cd89..4c92781db 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -152,9 +152,7 @@ def load_content_item def ordered_related_items(links) return [] if links["ordered_related_items_overrides"].present? - links["ordered_related_items"].presence || links.fetch( - "suggested_ordered_related_items", [] - ) + links["ordered_related_items"] end def format_banner_links(links, type) diff --git a/test/controllers/content_items_controller_test.rb b/test/controllers/content_items_controller_test.rb index 5e4c880c5..98f95de0b 100644 --- a/test/controllers/content_items_controller_test.rb +++ b/test/controllers/content_items_controller_test.rb @@ -153,16 +153,6 @@ class ContentItemsControllerTest < ActionController::TestCase assert_nil content_item["links"]["ordered_related_items"] end - test "gets item from content store and replaces ordered_related_items there are no existing links or overrides" do - content_item = content_store_has_schema_example("case_study", "case_study") - - get :show, params: { path: path_for(content_item) } - assert_response :success - assert_empty content_item["links"]["ordered_related_items"], "Content item should not have existing related links" - assert_not_empty content_item["links"]["suggested_ordered_related_items"], "Content item should have existing suggested related links" - assert_equal assigns[:content_item].content_item["links"]["ordered_related_items"], content_item["links"]["suggested_ordered_related_items"] - end - test "sets the expiry as sent by content-store" do content_item = content_store_has_schema_example("case_study", "case_study") stub_content_store_has_item(content_item["base_path"], content_item, max_age: 20)