From 44558ac3d69e4e749b31bbdf6b70a8d84602ada4 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 28 Nov 2011 17:30:56 +0100 Subject: Fix loading of title in the widget hotspot by metric --- .../core/widgets/hotspots/hotspot_metric.html.erb | 136 +++++++++++---------- 1 file changed, 70 insertions(+), 66 deletions(-) (limited to 'plugins/sonar-core-plugin') diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb index f43dbfb3fcc..1ba4c65a7b1 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb @@ -1,36 +1,36 @@ <% - metric = widget_properties["metric"] - metric = Metric.by_key('ncloc') unless metric - limit = widget_properties["numberOfLines"] || 5 - title = widget_properties["title"] - title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title && !title.blank? - - snapshots = nil - if metric.numeric? - snapshots_conditions=["snapshots.scope = 'FIL'", "snapshots.islast=:islast", "snapshots.status = 'P'"] - snapshots_values={:islast => true} - snapshots_conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))' - snapshots_values[:sid]=@snapshot.id - snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id) - snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%" - - measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL"] - measures_values = {} - measures_conditions << "project_measures.metric_id = :m_id" - measures_values[:m_id] = metric.id - - measures=ProjectMeasure.find(:all, - :joins => :snapshot, - :conditions => [ (snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)], - :order => "project_measures.value #{'DESC' if metric.direction<0}", - :limit => limit) - - snapshots=Snapshot.find(measures.map {|m| m.snapshot_id}, :include => 'project') - snapshots_by_id = {} - snapshots.each do |s| - snapshots_by_id[s.id]=s - end - end + metric = widget_properties["metric"] + metric = Metric.by_key('ncloc') unless metric + limit = widget_properties["numberOfLines"] || 5 + title = widget_properties["title"] + title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank? + + snapshots = nil + if metric.numeric? + snapshots_conditions=["snapshots.scope = 'FIL'", "snapshots.islast=:islast", "snapshots.status = 'P'"] + snapshots_values={:islast => true} + snapshots_conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))' + snapshots_values[:sid]=@snapshot.id + snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id) + snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%" + + measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL"] + measures_values = {} + measures_conditions << "project_measures.metric_id = :m_id" + measures_values[:m_id] = metric.id + + measures=ProjectMeasure.find(:all, + :joins => :snapshot, + :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)], + :order => "project_measures.value #{'DESC' if metric.direction<0}", + :limit => limit) + + snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project') + snapshots_by_id = {} + snapshots.each do |s| + snapshots_by_id[s.id]=s + end + end %> @@ -39,42 +39,46 @@ <%= message('widget.hotspot_metric.cannot_display_not_numeric_metric') -%> <% else %> -
-
- <%= message('widget.hotspot_metric.more') -%> + -

<%= title -%>

-
- - - -<% - if metric.direction > 0 - metric_max_value = measures.last.value - else - metric_max_value = measures.first.value - end - measures.each do |measure| - resource = snapshots_by_id[measure.snapshot_id].resource -%> - - - - +
- <%= link_to_resource(resource, resource.name, {:metric => metric.name}) -%> - - <%= format_measure(measure) -%> - -
-
-
-
+ + + -<% - end -%> - -
+ + + <% + if metric.direction > 0 + metric_max_value = measures.last.value + else + metric_max_value = measures.first.value + end + measures.each do |measure| + resource = snapshots_by_id[measure.snapshot_id].resource + %> + + + <%= link_to_resource(resource, resource.name, {:metric => metric.name}) -%> + + + <%= format_measure(measure) -%> + + +
+
+
+ + + <% + end + %> + + <% end %> -- cgit v1.2.3