2 metric = widget_properties["metric"]
3 metric = Metric.by_key('ncloc') unless metric
4 limit = widget_properties["numberOfLines"]
5 title = widget_properties["title"]
6 title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank?
10 snapshots_conditions=["snapshots.scope = 'FIL'", "snapshots.islast=:islast", "snapshots.status = 'P'"]
11 snapshots_values={:islast => true}
12 snapshots_conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'
13 snapshots_values[:sid]=@snapshot.id
14 snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id)
15 snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%"
17 measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL"]
19 measures_conditions << "project_measures.metric_id = :m_id"
20 measures_values[:m_id] = metric.id
22 measures=ProjectMeasure.find(:all,
24 :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)],
25 :order => "project_measures.value #{'DESC' if metric.direction<0}",
28 snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project')
31 snapshots_by_id[s.id]=s
37 <% unless snapshots && !snapshots.empty? %>
38 <h3><%= title -%></h3>
39 <span class="empty_widget"><%= message('no_results') -%></span>
42 <div class="line-block">
43 <div style="float:right">
44 <a href="<%= url_for_drilldown(metric) -%>"><%= message('widget.hotspot_metric.more') -%></a>
46 <h3><%= title -%></h3>
49 <table id="hotspots-<%= metric.name -%>-<%= widget.id -%>" class="data">
57 if metric.direction > 0
58 metric_max_value = measures.last.value
60 metric_max_value = measures.first.value
62 measures.each do |measure|
63 resource = snapshots_by_id[measure.snapshot_id].resource
65 <tr class="<%= cycle 'even', 'odd', :name => ('hotspot_metric' + widget.id.to_s) -%>">
67 <%= link_to_resource(resource, resource.name, {:metric => metric.name}) -%>
70 <%= format_measure(measure) -%>
73 <div class="barchart" style="width: <%= (measure.value*100/metric_max_value).round.to_i -%>%">
74 <div style="width: 100%;background-color:#777;"></div>