]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2138 Displaying differential values in % can be misleading
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 26 Jan 2011 10:59:42 +0000 (11:59 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 26 Jan 2011 11:00:15 +0000 (12:00 +0100)
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb

index 294710f54583456a33965919e0a140885a6ee556..dd1f5bd385c78f8ec7b603550bbd6849d436bbdd 100644 (file)
@@ -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'
index be2ca94720342a4d454ec65eb5c21496ef017962..1e553e99659a93c17a05d56df76d4e08e7af4e30 100644 (file)
@@ -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