Skip to content

Commit

Permalink
Fix corporate information pages error
Browse files Browse the repository at this point in the history
Some [corporate information pages](https://www.gov.uk/government/organisations/migration-advisory-committee/about)
are erroring because the list of IDs in corporate information groups in the
details hash doesn't match the list of linked corporate information pages
in the links hash.

Even if they do eventually resolve, these two lists will occasionally be
out of sync when they're updated because of the way our publishing system
works. We should defend against this so it doesn't error.

Resolves this [sentry error](https://sentry.io/organizations/govuk/issues/1813208304/?environment=production&project=202226&query=is%3Aunresolved&statsPeriod=14d)
  • Loading branch information
sihugh committed Nov 20, 2020
1 parent cd964b7 commit 0be0eac
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/presenters/content_item/corporate_information_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ def group_title_id(title)
end

def normalised_group_links(group)
group["contents"].map do |group_item|
normalised_group_item_link(group_item)
end
group["contents"].map { |group_item| normalised_group_item_link(group_item) }.compact
end

def normalised_group_item_link(group_item)
if group_item.is_a?(String)
group_item_link = corporate_information_page_links.find { |l| l["content_id"] == group_item }
view_context.link_to(group_item_link["title"], group_item_link["base_path"])
# it's possible for corporation_information_groups in details and links hashes to be out of sync.
view_context.link_to(group_item_link["title"], group_item_link["base_path"]) if group_item_link
else
view_context.link_to(group_item["title"], group_item["path"] || group_item["url"])
end
Expand Down

0 comments on commit 0be0eac

Please sign in to comment.