diff --git a/app/__init__.py b/app/__init__.py index e1ce3ccd5..fc9ad0a2d 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -38,6 +38,7 @@ from app.config import configs from app.extensions import antivirus_client, redis_client, zendesk_client from app.formatters import ( convert_to_boolean, + format_billions, format_date, format_date_human, format_date_normal, @@ -527,6 +528,7 @@ def setup_event_handlers(): def add_template_filters(application): for fn in [ + format_billions, format_datetime, format_datetime_24h, format_datetime_normal, diff --git a/app/formatters.py b/app/formatters.py index 2f9223a44..612e45113 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -515,3 +515,7 @@ def format_mobile_network(network): if network in ('three', 'vodafone', 'o2'): return network.capitalize() return 'EE' + + +def format_billions(count): + return humanize.intword(count) diff --git a/app/templates/views/performance.html b/app/templates/views/performance.html index 20e70551b..05235134c 100644 --- a/app/templates/views/performance.html +++ b/app/templates/views/performance.html @@ -22,28 +22,28 @@

Total messages

-
{{ total_notifications }}
+
{{ total_notifications|format_billions }}
total
{{ big_number( - email_notifications, + email_notifications|format_billions, label=email_notifications|message_count_noun('email'), smallest=True, ) }}
{{ big_number( - sms_notifications, + sms_notifications|format_billions, label=sms_notifications|message_count_noun('sms'), smallest=True, ) }}
{{ big_number( - letter_notifications, + letter_notifications|format_billions, label=letter_notifications|message_count_noun('letter'), smallest=True, ) }} diff --git a/tests/app/main/views/test_performance.py b/tests/app/main/views/test_performance.py index c6dc25074..6709d8b73 100644 --- a/tests/app/main/views/test_performance.py +++ b/tests/app/main/views/test_performance.py @@ -117,10 +117,10 @@ def test_should_render_performance_page( '' 'Messages sent since May 2016 ' 'Total messages ' - '1789000000 total ' - '1,123,000,000 emails ' - '987,654,321 text messages ' - '1,234,567 letters ' + '1.8 billion total ' + '1.1 billion emails ' + '987.7 million text messages ' + '1.2 million letters ' '' 'Date Emails Text messages Letters ' '21 February 2021 1,234,567 123,456 123 '