From 4f06d089b39fdcbeff0a733fba3387bf95b73e75 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 27 Nov 2019 13:36:58 +0000 Subject: [PATCH] Switch to using the government from links, rather than the details Currently, Whitehall includes the details of the associated government for some content in the details. Now Whitehall also links the content to a content item representing the government. Using the linking approach is preferable going forward, as that means the Publishing API can take care of updating the content store when a government changes (becoming historical), rather than Whitehall having to publish new editions. This change to Government Frontend can be deployed once all the relevant content has been linked to the correct government, something which is being done in bulk from Whitehall. --- app/presenters/content_item/political.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/presenters/content_item/political.rb b/app/presenters/content_item/political.rb index 14282537e..3f3e8d70a 100644 --- a/app/presenters/content_item/political.rb +++ b/app/presenters/content_item/political.rb @@ -15,7 +15,14 @@ def political? end def historical? - content_item["details"].include?("government") && !content_item["details"]["government"]["current"] + government_current = content_item.dig( + "links", "government", 0, "details", "current" + ) + + # Treat no government as not historical + return false if government_current.nil? + + !government_current end end end