From 509931aa4cbe60edd81949106d64961caaaedda2 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Wed, 27 Sep 2023 20:17:43 +0200 Subject: [PATCH] format numbers in reporting counters (#161) * format numbers in reporting counters * remarks --- CHANGELOG.md | 1 + .../web/ui/helpers/application_helper.rb | 5 +-- .../web/ui/pro/views/consumers/_counters.erb | 32 ++++++++++++++----- .../web/ui/views/consumers/_counters.erb | 28 ++++++++++++---- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 524771b1..b48dfd90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.7.5 (Unreleased) - [Enhancement] Update order of topics creation for the setup of Web to support zero-downtime setup of Web in running Karafka projects. +- [Enhancement] Add space delimiter to counters numbers to make them look better. - [Fix] Fix a case where charts aggregated data would not include all topics. - [Fix] Make sure, that most recent per partition data for Health is never overwritten by an old state from a previous partition owner. - [Fix] Cache assets for 1 year instead of 7 days. diff --git a/lib/karafka/web/ui/helpers/application_helper.rb b/lib/karafka/web/ui/helpers/application_helper.rb index 503617d2..a4ad9c9c 100644 --- a/lib/karafka/web/ui/helpers/application_helper.rb +++ b/lib/karafka/web/ui/helpers/application_helper.rb @@ -101,12 +101,13 @@ def format_memory(mem_kb) # Converts number to a more friendly delimiter based version # @param number [Numeric] + # @param delimiter [String] delimiter (comma by default) # @return [String] number with delimiter - def number_with_delimiter(number) + def number_with_delimiter(number, delimiter = ',') return '' unless number parts = number.to_s.to_str.split('.') - parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, '\1,') + parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}") parts.join('.') end diff --git a/lib/karafka/web/ui/pro/views/consumers/_counters.erb b/lib/karafka/web/ui/pro/views/consumers/_counters.erb index f78aedaf..1989e064 100644 --- a/lib/karafka/web/ui/pro/views/consumers/_counters.erb +++ b/lib/karafka/web/ui/pro/views/consumers/_counters.erb @@ -6,40 +6,56 @@