aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-04 11:41:15 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-07 17:26:43 +0100
commit6cf62f0adc9677404df3ff457135591c17ad89a5 (patch)
tree08b31db10e52e92575a6343768f93e46b13266b7 /server/sonar-web/src/main
parent541c15654fc024534c45710b30b9cfc8ec551d96 (diff)
downloadsonarqube-6cf62f0adc9677404df3ff457135591c17ad89a5.tar.gz
sonarqube-6cf62f0adc9677404df3ff457135591c17ad89a5.zip
SONAR-6939 ability for plugins to override the decimal scale of float
measures
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb8
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1005_add_decimal_scale_to_metrics.rb33
2 files changed, 37 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
index e3195f67456..4b42ca50ded 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
@@ -79,7 +79,7 @@ class ProjectMeasure < ActiveRecord::Base
when Metric::VALUE_TYPE_INT
number_with_precision(value(), :precision => 0)
when Metric::VALUE_TYPE_FLOAT
- number_with_precision(value(), :precision => 1)
+ number_with_precision(value(), :precision => (metric().decimal_scale||1))
when Metric::VALUE_TYPE_PERCENT
number_to_percentage(value(), {:precision => 1})
when Metric::VALUE_TYPE_MILLISEC
@@ -108,12 +108,12 @@ class ProjectMeasure < ActiveRecord::Base
when Metric::VALUE_TYPE_INT
number_with_precision(val, :precision => 0)
when Metric::VALUE_TYPE_FLOAT
- number_with_precision(val, :precision => 1)
+ number_with_precision(val, :precision => (metric().decimal_scale||1))
when Metric::VALUE_TYPE_PERCENT
if (options[:variation]==true)
- number_with_precision(val, :precision => 1)
+ number_with_precision(val, :precision => (metric().decimal_scale||1))
else
- number_to_percentage(val, {:precision => 1})
+ number_to_percentage(val, {:precision => (metric().decimal_scale||1)})
end
when Metric::VALUE_TYPE_MILLISEC
millisecs_formatted_value(val)
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1005_add_decimal_scale_to_metrics.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1005_add_decimal_scale_to_metrics.rb
new file mode 100644
index 00000000000..48d0bd5a1e2
--- /dev/null
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1005_add_decimal_scale_to_metrics.rb
@@ -0,0 +1,33 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# SonarQube 5.3
+# SONAR-6939
+#
+class AddDecimalScaleToMetrics < ActiveRecord::Migration
+
+ def self.up
+ add_column 'metrics', 'decimal_scale', :integer, :null => true
+ end
+
+end
+
+