diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index 1bacf1139..5fd42027e 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -30,4 +30,8 @@ module StatsHelper opt[:data][:graph] = admin_api_stats_path(budget_investments: true) content_tag :div, "", opt end + + def number_to_stats_percentage(number, options = {}) + number_to_percentage(number, { strip_insignificant_zeros: true, precision: 2 }.merge(options)) + end end diff --git a/app/views/budgets/stats/show.html.erb b/app/views/budgets/stats/show.html.erb index 46c09d574..c38852615 100644 --- a/app/views/budgets/stats/show.html.erb +++ b/app/views/budgets/stats/show.html.erb @@ -108,9 +108,7 @@
<%= t("budgets.stats.total_female_participants").upcase %> - (<%= number_to_percentage(@stats[:female_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= number_to_stats_percentage(@stats[:female_percentage]) %>)
<%= @stats[:total_female_participants] %> @@ -121,9 +119,7 @@
<%= t("budgets.stats.total_male_participants").upcase %> - (<%= number_to_percentage(@stats[:male_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= number_to_stats_percentage(@stats[:male_percentage]) %>)
<%= @stats[:total_male_participants] %> @@ -154,17 +150,13 @@ <% percentage_age_count = all_ages_count == 0 ? 0 : (count / all_ages_count * 100) - formatted_percentage_age_count = number_to_percentage(percentage_age_count, - strip_insignificant_zeros: true, - precision: 2) + formatted_percentage_age_count = number_to_stats_percentage(percentage_age_count) %> <%= count %> (<%= formatted_percentage_age_count %>)