# HG changeset patch # User Jan Vrany # Date 1458340909 0 # Node ID c9a8fa71d8fc6272160e459a970333f94409c3cd # Parent 1109121c906f1510b4c6af2c311a3b0c70f6d505 Web: Fixed filtering by tags in "Results" page "Results" page not allow for filtering by tags. * If both, configuration and tags are specified, only reports for specified configurations AND with at least one of the specified tags are shown. * If only tags are specified, then all reports on all configurations having at keast one of specified tags are shown. Kudos to Jan Kurs for forcing me to fix this :-) diff -r 1109121c906f -r c9a8fa71d8fc web/app/models/results_filter.rb --- a/web/app/models/results_filter.rb Fri Mar 18 19:36:12 2016 +0000 +++ b/web/app/models/results_filter.rb Fri Mar 18 22:41:49 2016 +0000 @@ -14,17 +14,38 @@ BenchmarkConfiguration.where(id: benchmark_configurations.compact) end + # Return benchmark reports (batches in webapp) based on criterie. + # The filtering works as folloeing: + # * if selected configurations and selected benchmarks are BOTH ARE EMPTYy, + # return an empty list. + # * if selected CONFIGURATIONS ARE EMPTY, then filter by selected tags. + # * if selected TAGS ARE EMPTY, then filter by selected configrations + # * if BOTH ARE NON-EMPTY, then return only those having one of the + # selected configurations and one of the tags def filtered_batches - BenchmarkBatch. - includes( - :tags, - :benchmark_configuration, - benchmark_results: [ - :benchmark_durations, - :benchmark_info - ]). - where(benchmark_configuration_id: benchmark_configurations.compact). - order("performed_at desc") + benchmark_configurations.compact! + benchmark_configurations.reject! { | e | e.empty? } + tags.compact! + tags.reject! { | e | e.empty? } + + if benchmark_configurations.empty? and tags.empty? then + return [] + end + batches = BenchmarkBatch.includes( + :tags, + :benchmark_configuration, + benchmark_results: [ + :benchmark_durations, + :benchmark_info + ]) + if not benchmark_configurations.empty? then + batches = batches.where(benchmark_configuration_id: benchmark_configurations) + end + if not tags.empty? then + batches = batches.joins(:tags).where(tags: { id: tags}) + end + batches = batches.order("performed_at desc") + return batches end end diff -r 1109121c906f -r c9a8fa71d8fc web/app/views/results/index.html.erb --- a/web/app/views/results/index.html.erb Fri Mar 18 19:36:12 2016 +0000 +++ b/web/app/views/results/index.html.erb Fri Mar 18 22:41:49 2016 +0000 @@ -28,60 +28,66 @@ <% end %> -<% @results_filter.benchmark_configurations_relation.each do |configuration| %> -
- <% panel_id = "panel-for-configuration-#{configuration.id}" %> - <% panel_body_id = "panel-body-for-configuration-#{configuration.id}" %> -
-
-
- <%= link_to configuration.name, - "#" + panel_body_id, - data: { toggle: "collapse", - parent: "#" + panel_id } %> -
-
-
- <%= render "index/timeline_table", benchmark_configuration: configuration %> +<% filtered_batches = @results_filter.filtered_batches() %> +<% if not filtered_batches.empty? %> + <% @results_filter.benchmark_configurations_relation.each do |configuration| %> +
+ <% panel_id = "panel-for-configuration-#{configuration.id}" %> + <% panel_body_id = "panel-body-for-configuration-#{configuration.id}" %> +
+
+
+ <%= link_to configuration.name, + "#" + panel_body_id, + data: { toggle: "collapse", + parent: "#" + panel_id } %> +
+
+
+ <%= render "index/timeline_table", benchmark_configuration: configuration %> +
-
-<% end %> - -
+ <% end %> - <% @results_filter.filtered_batches.each do |batch| %> - <% panel_id = "benchmark-batch-#{batch.id}" %> - <% panel_body_id = "benchmark-batch-details-#{batch.id}" %> -
-
-
-
-
- <%= link_to l(batch.performed_at), - "#" + panel_body_id, - data: { toggle: "collapse", - parent: "#" + panel_id } %> +
+ <% filtered_batches.each do |batch| %> + <% panel_id = "benchmark-batch-#{batch.id}" %> + <% panel_body_id = "benchmark-batch-details-#{batch.id}" %> +
+
+
+
+
+ <%= link_to l(batch.performed_at), + "#" + panel_body_id, + data: { toggle: "collapse", + parent: "#" + panel_id } %> +
+
+ <%= batch.benchmark_configuration.name %> + <%= batch.tags.map(&:name).join(", ") %> +
+
+ <%= link_to('[json]', archive_path(batch.id, format: 'json')) %> + <%= link_to('[csv]', archive_path(batch.id, format: 'csv')) %> +
-
- <%= batch.benchmark_configuration.name %> - <%= batch.tags.map(&:name).join(", ") %> -
-
- <%= link_to('[json]', archive_path(batch.id, format: 'json')) %> - <%= link_to('[csv]', archive_path(batch.id, format: 'csv')) %> +
+
+
+ <%= render "index/benchmarks_table", batch: batch %>
-
-
- <%= render "index/benchmarks_table", batch: batch %> -
-
-
- <% end %> -
+ <% end %> +
+<% else %> +
+

Sorry, no benchmark reports match the above criterie

+
+<% end %> \ No newline at end of file