2 metric = widget_properties["metric"] || Metric.by_key('ncloc')
6 limit = widget_properties["numberOfLines"]
7 title = widget_properties["title"]
8 title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank?
11 if metric.numeric? && !@snapshot.leaves_qualifiers.empty?
12 snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"]
13 snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true}
14 snapshots_conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'
15 snapshots_values[:sid]=@snapshot.id
16 snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id)
17 snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%"
19 measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL", "project_measures.person_id IS NULL"]
21 measures_conditions << "project_measures.metric_id = :m_id"
22 measures_values[:m_id] = metric.id
24 measures=ProjectMeasure.find(:all,
26 :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)],
27 :order => "project_measures.value #{'DESC' if metric.direction<0}",
30 snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project')
33 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, h(resource.name), {:metric => metric.name}) -%>
69 <td class="right nowrap">
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>