org.sonar.server.dashboard.widget.hotspot_metric.html.erb Maven / Gradle / Ivy
<%
metric = widget_properties["metric"] || Metric.by_key('ncloc')
if measure(metric)
limit = widget_properties["numberOfLines"]
title = widget_properties["title"]
title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank?
snapshots = nil
if metric.numeric? && [email protected]_qualifiers.empty?
snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"]
snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true}
snapshots_conditions << '(snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path)'
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.person_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
unless snapshots && !snapshots.empty? %>
<%= title -%>
<% else %>
<%= 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, h(resource.name), {:metric => metric.name, :class => 'underlined-link'}) -%>
<%= format_measure(measure) -%>
<%
end
%>
<% end %>
<% end %>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy