2 limit = widget_properties["numberOfLines"]
3 metric = Metric.by_key('weighted_violations')
5 snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"]
6 snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true}
7 snapshots_conditions << '(snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path)'
8 snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id)
9 snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%"
11 measures_conditions = ["project_measures.rule_id IS NULL AND project_measures.characteristic_id IS NULL AND project_measures.person_id IS NULL"]
13 measures_conditions << "project_measures.metric_id = :m_id"
14 measures_values[:m_id] = metric.id
16 measures=ProjectMeasure.find(:all,
18 :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)],
19 :order => "project_measures.value #{'DESC' if metric.direction<0}",
21 measures=measures.select{|m| m.text_value.present?}
23 snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project')
26 snapshots_by_id[s.id]=s
29 title = message('widget.hotspot_most_violated_resources.name')
34 <h3><%= title -%></h3>
35 <span class="empty_widget"><%= message('widget.hotspot_most_violated_resources.no_resource') -%></span>
41 <div class="line-block">
42 <div style="float:right">
43 <a href="<%= url_for_drilldown(metric) -%>"><%= message('widget.hotspot_metric.more') -%></a>
45 <h3><%= title -%></h3>
48 <table id="most-violated-resources-<%= widget.id -%>" class="data">
51 <th colspan="11"></th>
56 measures.each do |measure|
57 resource = snapshots_by_id[measure.snapshot_id].resource
58 violations_per_severity={}
59 measure.text_value.split(';').each do |part|
60 fields=part.split('=')
61 violations_per_severity[fields[0]]=fields[1]
64 <tr class="<%= cycle 'even', 'odd', :name => ('hotspot_most_violated_resources' + widget.id.to_s) -%>">
66 <%= link_to_resource(resource, h(resource.name), {:tab => :violations}) -%>
68 <td class="small right">
69 <i class="icon-severity-blocker"></i>
71 <td class="small left">
72 <%= violations_per_severity["BLOCKER"] ? violations_per_severity["BLOCKER"].to_s : "0" -%>
74 <td class="small right">
75 <i class="icon-severity-critical"></i>
77 <td class="small left">
78 <%= violations_per_severity["CRITICAL"] ? violations_per_severity["CRITICAL"].to_s : "0" -%>
80 <td class="small right">
81 <i class="icon-severity-major"></i>
83 <td class="small left">
84 <%= violations_per_severity["MAJOR"] ? violations_per_severity["MAJOR"].to_s : "0" -%>
86 <td class="small right">
87 <i class="icon-severity-minor"></i>
89 <td class="small left">
90 <%= violations_per_severity["MINOR"] ? violations_per_severity["MINOR"].to_s : "0" -%>
92 <td class="small right">
93 <i class="icon-severity-info"></i>
95 <td class="small left">
96 <%= violations_per_severity["INFO"] ? violations_per_severity["INFO"].to_s : "0" -%>