From 1846ed6b920ea852cf7a6ac4a4140a7a7eb487b1 Mon Sep 17 00:00:00 2001 From: pezholio Date: Tue, 5 Nov 2024 13:52:16 +0000 Subject: [PATCH] Change number presentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the numbers more in line with how they are presented elsewhere, as well as using shortened forms instead of “Thousand, Million” etc --- .../document/show/host_editions_table_component.rb | 2 +- .../document/show/host_editions_table_component_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.rb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.rb index b2d3a571f11..5abb8c8ede6 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.rb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.rb @@ -22,7 +22,7 @@ def rows text: content_item.document_type.humanize, }, { - text: content_item.unique_pageviews ? number_to_human(content_item.unique_pageviews) : nil, + text: content_item.unique_pageviews ? number_to_human(content_item.unique_pageviews, format: "%n%u", precision: 3, significant: true, units: { thousand: "k", million: "m", billion: "b" }) : nil, }, { text: organisation_link(content_item), diff --git a/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb index 475dfedeb45..102ad703d4a 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb @@ -60,7 +60,7 @@ def self.it_returns_unknown_user assert_selector "tbody .govuk-table__cell", text: host_content_item.title assert_selector "tbody .govuk-table__cell", text: host_content_item.document_type.humanize - assert_selector "tbody .govuk-table__cell", text: "1.2 Million" + assert_selector "tbody .govuk-table__cell", text: "1.2m" assert_selector "tbody .govuk-table__cell", text: host_content_item.publishing_organisation["title"] assert_selector "tbody .govuk-table__cell", text: "#{time_ago_in_words(host_content_item.last_edited_at)} ago by #{user.name}" assert_link user.name, { href: "mailto:#{user.email}" }