<%
+ rows_by_metric_id={}
+
# Retrieve widget settings
metric_ids = []
(1..10).each do |index|
metric=widget_properties["metric#{index}"]
if metric
metric_ids << metric.id
+ row=Sonar::TimemachineRow.new(metric)
+ rows_by_metric_id[metric.id]=row
end
end
if metric_ids.empty?
)
- if measures.size > 0
- # Prepare the rows to display
- snapshot_by_id={}
- snapshots.each do |s|
- snapshot_by_id[s.id]=s
- end
- rows_by_metric_id={}
- measures.each do |measure|
- next unless measure.metric
-
- if measure.metric.timemachine? && (measure.value || measure.text_value)
- row=rows_by_metric_id[measure.metric_id]
- unless row
- row=Sonar::TimemachineRow.new(measure.metric)
- rows_by_metric_id[measure.metric_id]=row
- end
+ # Prepare the rows to display
+ snapshot_by_id={}
+ snapshots.each do |s|
+ snapshot_by_id[s.id]=s
+ end
+ measures.each do |measure|
+ next unless measure.metric
- #optimization : avoid eager loading of snapshots
- measure.snapshot=snapshot_by_id[measure.snapshot_id]
- row.add_measure(measure)
- end
+ if measure.metric.timemachine? && (measure.value || measure.text_value)
+ row=rows_by_metric_id[measure.metric_id]
+
+ #optimization : avoid eager loading of snapshots
+ measure.snapshot=snapshot_by_id[measure.snapshot_id]
+ row.add_measure(measure)
end
+ end
- # Create the list of rows to display in the same order as defined by the user
- rows=[]
- metric_ids.each do |metric_id|
- row = rows_by_metric_id[metric_id]
- if row
- rows<<row
- end
+ # Create the list of rows to display in the same order as defined by the user
+ rows=[]
+ metric_ids.each do |metric_id|
+ row = rows_by_metric_id[metric_id]
+ if row
+ rows<<row
end
+ end
- # Should display the sparkline?
- sparkline_urls_by_row = {}
- if widget_properties["displaySparkLine"]
- rows.each do |row|
- sparkline_url = row.sparkline_url
- sparkline_urls_by_row[row] = sparkline_url if sparkline_url
- end
+ # Should display the sparkline?
+ sparkline_urls_by_row = {}
+ if widget_properties["displaySparkLine"]
+ rows.each do |row|
+ sparkline_url = row.sparkline_url
+ sparkline_urls_by_row[row] = sparkline_url if sparkline_url
end
- display_sparkline = !sparkline_urls_by_row.empty?
+ end
+ display_sparkline = !sparkline_urls_by_row.empty?
%>
<div style="overflow: auto;font-size: 12px;padding: 1px;">
sparkline_url = sparkline_urls_by_row[row]
%>
<td width="1%">
- <%= image_tag(sparkline_url) %>
+ <%= image_tag(sparkline_url) if sparkline_url %>
</td>
<% end %>
</tr>
</table>
</div>
-
-<% else %>
-
-<span class="empty_widget"><%= message('widget.time_machine.no_data_for_selected_metrics') -%></span>
-
-<% end %>
\ No newline at end of file