]> source.dussan.org Git - sonarqube.git/blob
8685fc47ce889bd17315e89063b21de987567158
[sonarqube.git] /
1 <%
2   limit = widget_properties["numberOfLines"]
3   unless limit
4     limit = 5
5   end
6
7   metric = Metric.find(:first, :conditions => "name = 'weighted_violations'")
8   
9   snapshots_conditions = ["snapshots.scope = 'FIL'"]
10   snapshots_values = {}
11   snapshots_conditions << "(snapshots.qualifier = 'CLA' OR snapshots.qualifier = 'FIL' OR snapshots.qualifier = 'TRK')"
12   snapshots_conditions << "project_measures.rule_id IS NULL"
13   snapshots_conditions << "project_measures.characteristic_id IS NULL"
14   snapshots_conditions << "snapshots.path LIKE :path"
15   snapshots_values[:path] = "#{@snapshot.path}#{@snapshot.id}.%"
16   snapshots_conditions << "project_measures.metric_id = :m_id"
17   snapshots_values[:m_id] = metric.id
18   snapshots_conditions << "snapshots.root_project_id = :root_id"
19   snapshots_values[:root_id] = @snapshot.root_project_id
20
21   snapshots=Snapshot.find(:all, 
22                           :conditions => [snapshots_conditions.join(' AND '), snapshots_values], 
23                           :include => ['project', 'measures'],
24                           :order => "project_measures.value DESC",
25                           :limit => limit)
26 %>
27
28 <div class="line-block">
29   <div style="float:right">
30     <a href="<%= url_for_drilldown(metric) -%>"><%= message('widget.hotspot_metric.more') -%></a>
31   </div>
32   <h3><%= message('widget.hotspot_most_violated_resources.name') -%></h3>
33 </div>
34
35 <table id="most-violated-resources-<%= widget.id -%>" class="data">
36   <thead><tr><th colspan="11"/></tr></thead>
37   <tbody>
38 <%
39   snapshots.each do |s|
40     resource = s.resource
41     violations_per_severity={}
42     s.measure(metric).text_value.split(';').each do |part|
43       fields=part.split('=')
44       violations_per_severity[fields[0]]=fields[1]
45     end
46 %>
47     <tr class="<%= cycle 'even','odd', :name => ('hotspot_most_violated_resources' + widget.id.to_s) -%>">
48       <td>
49         <%= link_to_resource(resource, resource.name) -%>
50       </td>
51       <td class="small right">
52         <%= image_tag('priority/BLOCKER.png') -%>
53       </td>
54       <td class="small left">
55         <%= violations_per_severity["BLOCKER"] ? violations_per_severity["BLOCKER"].to_s : "0" -%>
56       </td>
57       <td class="small right">
58         <%= image_tag('priority/CRITICAL.png') -%>
59       </td>
60       <td class="small left">
61         <%= violations_per_severity["CRITICAL"] ? violations_per_severity["CRITICAL"].to_s : "0" -%>
62       </td>
63       <td class="small right">
64         <%= image_tag('priority/MAJOR.png') -%>
65       </td>
66       <td class="small left">
67         <%= violations_per_severity["MAJOR"] ? violations_per_severity["MAJOR"].to_s : "0" -%>
68       </td>
69       <td class="small right">
70         <%= image_tag('priority/MINOR.png') -%>
71       </td>
72       <td class="small left">
73         <%= violations_per_severity["MINOR"] ? violations_per_severity["MINOR"].to_s : "0" -%>
74       </td>
75       <td class="small right">
76         <%= image_tag('priority/INFO.png') -%>
77       </td>
78       <td class="small left">
79         <%= violations_per_severity["INFO"] ? violations_per_severity["INFO"].to_s : "0" -%>
80       </td>    
81     </tr>
82 <%
83   end
84 %>
85   </tbody>
86 </table>