From: Fabrice Bellingard Date: Tue, 17 Jul 2012 11:59:58 +0000 (+0200) Subject: SONAR-3556 Fix issue by using the metric value type for formatting X-Git-Tag: 3.2~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3a0f525a09e4f6258cd7694f26aab630fff692e5;p=sonarqube.git SONAR-3556 Fix issue by using the metric value type for formatting --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb index a756e495f97..17b0543a2e5 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb @@ -1,7 +1,7 @@ <% # Retrieve widget settings metric_data_map = {} - metric_name_map = {} + metric_map = {} metrics_specified = false (1..3).each do |index| metric=widget_properties["metric#{index}"] @@ -11,7 +11,7 @@ metrics_specified = true if measure(metric) metric_data_map[metric.id] = [] - metric_name_map[metric.id] = metric.short_name + metric_map[metric.id] = metric end end end @@ -19,7 +19,7 @@ # No metric has been selected, it's the first time the widget is displayed: 'ncloc' is the default metric ncloc = Metric.by_name('ncloc') metric_data_map[ncloc.id] = [] - metric_name_map[ncloc.id] = message('metric.ncloc.name') + metric_map[ncloc.id] = ncloc end chartHeight = widget_properties["chartHeight"] @@ -45,10 +45,10 @@ js_data = "[" js_snapshots = "[" js_metrics = "[" - total_number_of_metrics = metric_name_map.keys.size() + total_number_of_metrics = metric_map.keys.size() metric_data_map.keys.each_with_index() do |metric_id, index| unless metric_data_map[metric_id].empty? - js_metrics += "\"" + metric_name_map[metric_id] + "\"," + js_metrics += "\"" + metric_map[metric_id].short_name + "\"," js_data += "[" metric_data_map[metric_id].each() do |metric_data| # for every metric value, we need to check that the corresponding snapshot has values for each metric (if not, Protovis won't be able to display) @@ -57,7 +57,7 @@ # Only Oracle returns a Time object, so let's parse this string if it's not a Time instance m_date = Time.parse(metric_data[:date]) unless m_date.is_a? Time m_value = sprintf("%0.02f", metric_data[:value]) - m_value_localized = (m_value.end_with? '.00') ? number_with_precision(metric_data[:value], :precision => 0).to_s : number_with_precision(metric_data[:value], :precision => 1).to_s + m_value_localized = ProjectMeasure.new (:metric => metric_map[metric_id]).format_numeric_value(metric_data[:value], {}) js_data += "{x:d(" js_data += m_date.year.to_s js_data += ","