From: simonbrandhof Date: Wed, 26 Jan 2011 10:59:42 +0000 (+0100) Subject: SONAR-2138 Displaying differential values in % can be misleading X-Git-Tag: 2.6~107 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=acbb9609fdfc8acbdd1bbec5e8ade31afa6f64eb;p=sonarqube.git SONAR-2138 Displaying differential values in % can be misleading --- 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