From acbb9609fdfc8acbdd1bbec5e8ade31afa6f64eb Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 26 Jan 2011 11:59:42 +0100 Subject: SONAR-2138 Displaying differential values in % can be misleading --- .../src/main/webapp/WEB-INF/app/helpers/application_helper.rb | 2 +- .../src/main/webapp/WEB-INF/app/models/project_measure.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'sonar-server') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 294710f5458..dd1f5bd385c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -494,7 +494,7 @@ module ApplicationHelper if m val=variation_value(m, options) if val - formatted_val=(val>=0 ? "+#{m.format_numeric_value(val)}" : m.format_numeric_value(val)) + formatted_val=(val>=0 ? "+" : "") + m.format_numeric_value(val, :variation => true) css_class='' if options[:color]||true css_class='var' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index be2ca947203..1e553e99659 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -88,7 +88,7 @@ class ProjectMeasure < ActiveRecord::Base end end - def format_numeric_value(val) + def format_numeric_value(val, options={}) if metric.nil? return val.to_s end @@ -99,7 +99,11 @@ class ProjectMeasure < ActiveRecord::Base when Metric::VALUE_TYPE_FLOAT number_with_precision(val, :precision => 1) when Metric::VALUE_TYPE_PERCENT - number_to_percentage(val, {:precision => 1}) + if (options[:variation]==true) + number_with_precision(val, :precision => 1) + else + number_to_percentage(val, {:precision => 1}) + end when Metric::VALUE_TYPE_MILLISEC millisecs_formatted_value(val) else -- cgit v1.2.3