From 2796325b4b87e9b273f7b4fe0649ae3f6297a51b Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Tue, 27 Mar 2012 10:34:42 +0200 Subject: [PATCH] SONAR-3354 Display empty table instead of message if no measures --- .../core/widgets/time_machine.html.erb | 76 +++++++++---------- .../resources/org/sonar/l10n/core.properties | 1 - 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb index ea8e590b194..3d5f376e6c4 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb @@ -1,10 +1,14 @@ <% + 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? @@ -30,47 +34,41 @@ ) - 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<
@@ -114,7 +112,7 @@ sparkline_url = sparkline_urls_by_row[row] %> - <%= image_tag(sparkline_url) %> + <%= image_tag(sparkline_url) if sparkline_url %> <% end %> @@ -124,9 +122,3 @@
- -<% else %> - -<%= message('widget.time_machine.no_data_for_selected_metrics') -%> - -<% end %> \ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index dd803c76893..d41cd3320c9 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -677,7 +677,6 @@ widget.timeline.timeline_not_displayed=No history widget.time_machine.name=History Table widget.time_machine.description=Displays up to 10 metrics in a table, showing their value for a specified number of past snapshots. -widget.time_machine.no_data_for_selected_metrics=No data for selected metrics widget.ckjm.name=Chidamber & Kemerer widget.ckjm.description=Reports on LCOM4 and RFC average and distribution. -- 2.39.5