Results tab refactored to allow filtering.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 13 Oct 2014 10:23:12 +0100
changeset 226 4e1806b2569a
parent 225 1717c8a3eba6
child 227 0a78e48d766a
Results tab refactored to allow filtering. Results tab now allows filtering by tags and by configurations. This become necessay as number of results grows.
web/app/assets/javascripts/compare.js
web/app/assets/stylesheets/application.css
web/app/assets/stylesheets/results.css.scss
web/app/controllers/compare_controller.rb
web/app/controllers/results_controller.rb
web/app/helpers/results_helper.rb
web/app/models/results_filter.rb
web/app/views/archive/index.html.erb
web/app/views/compare/index.html.erb
web/app/views/results/_results_nav.html.erb
web/app/views/results/configuration_results.html.erb
web/app/views/results/index.html.erb
--- a/web/app/assets/javascripts/compare.js	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/assets/javascripts/compare.js	Mon Oct 13 10:23:12 2014 +0100
@@ -1,2 +1,7 @@
 // Place all the behaviors and hooks related to the matching controller here.
 // All this logic will automatically be available in application.js.
+
+
+$('#check_all').click(function() {
+  var i;
+}
\ No newline at end of file
--- a/web/app/assets/stylesheets/application.css	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/assets/stylesheets/application.css	Mon Oct 13 10:23:12 2014 +0100
@@ -20,3 +20,31 @@
  a.data-download {
   float: right;
  }
+
+
+span.column05 {
+  display: inline-block;
+  width: 05%;
+}
+
+ span.column10 {
+  display: inline-block;
+  width: 10%;
+}
+
+span.column20 {
+  display: inline-block;
+  width: 20%;
+}
+
+span.column30 {
+  display: inline-block;
+  width: 30%;
+}
+
+span.column40 {
+  display: inline-block;
+  width: 40%;
+}
+
+
--- a/web/app/assets/stylesheets/results.css.scss	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/assets/stylesheets/results.css.scss	Mon Oct 13 10:23:12 2014 +0100
@@ -1,3 +1,24 @@
 // Place all the styles related to the Results controller here.
 // They will automatically be included in application.css.
 // You can use Sass (SCSS) here: http://sass-lang.com/
+
+span.column10 {
+	display: inline-block;
+	width: 10%;
+}
+
+span.column20 {
+	display: inline-block;
+	width: 20%;
+}
+
+span.column30 {
+	display: inline-block;
+	width: 30%;
+}
+
+span.column40 {
+	display: inline-block;
+	width: 40%;
+}
+
--- a/web/app/controllers/compare_controller.rb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/controllers/compare_controller.rb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,7 +1,13 @@
 class CompareController < ApplicationController
   def index
     @compare_query = CompareQuery.new(
-      benchmark_infos: BenchmarkInfo.all.inject({}) { |acc, val| acc[val.id.to_s] = val.id.to_s; acc })
+      # Following line would make all benchmarks ticked by default.
+      # this is not wanted as there may be tons of benchmarks...
+      # benchmark_infos: BenchmarkInfo.all.inject({}) { |acc, val| acc[val.id.to_s] = val.id.to_s; acc }
+
+      # Following line makes none of them tocked by default...
+      benchmark_infos: {}
+    )
     @benchmark_infos = @compare_query.filtered_benchmark_infos
   end
 
--- a/web/app/controllers/results_controller.rb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/controllers/results_controller.rb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,13 +1,15 @@
 class ResultsController < ApplicationController
   def index
+    @results_filter = ResultsFilter.new(results_filter_params())
   end
 
-  def configuration_results
-    @benchmark_configuration = BenchmarkConfiguration.find(params[:id])
+  private
 
-    respond_to do |format|
-      format.html { }
-      format.js { render json: @benchmark_configuration.to_json, callback: params[:callback] }
+  def results_filter_params
+    if params[:results_filter] then
+      return params.require(:results_filter).permit!
+    else
+      return {}
     end
   end
 
--- a/web/app/helpers/results_helper.rb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/helpers/results_helper.rb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,2 +1,9 @@
 module ResultsHelper
+  def benchmark_configurations_options
+    return BenchmarkConfiguration.all.map { |b| [b.name, b.id] }
+  end
+
+  def tags_options
+    return Tag.all.map { |b| [b.name, b.id] }
+  end
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/app/models/results_filter.rb	Mon Oct 13 10:23:12 2014 +0100
@@ -0,0 +1,20 @@
+class ResultsFilter
+  include ActiveModel::Model
+
+  attr_accessor :benchmark_configurations
+  attr_accessor :tags
+
+  def initialize(*args)
+    super
+    @benchmark_configurations ||= {}
+    @tags ||= {}
+  end
+
+
+  def filtered_results()
+    return BenchmarkBatch.where(benchmark_configuration_id: @benchmark_configurations.keys)
+  end
+
+  private
+
+end
--- a/web/app/views/archive/index.html.erb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/views/archive/index.html.erb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,7 +1,5 @@
 <%= currently_at "archive" %>
 
-<h1>Archive</h1>
-
 <table class="table">
   <thead>
     <tr>
--- a/web/app/views/compare/index.html.erb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/views/compare/index.html.erb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,21 +1,18 @@
 <%= currently_at "compare" %>
 
-<div class="span3">
+
+
   <div class="well">
     <%= form_for @compare_query,
       method: 'get',
       url: filter_compare_index_path,
-      builder: CalipelFormBuilder do |f| %> 
-      <%= f.fieldset_item "Comparing" do %>
+      builder: CalipelFormBuilder do |f| %>
+      <%= f.fieldset_item "Benchmarks" do %>
         <%= f.checkboxes_item :benchmark_infos, all_benchmarks_options %>
         <%= f.submit_item "Compare" %>
       <% end %>
     <% end %>
   </div>
-</div>
-
-<div class="span9">
-    <%= render "index/compare_table", 
-      benchmark_configurations: all_configurations, 
+    <%= render "index/compare_table",
+      benchmark_configurations: all_configurations,
       benchmark_infos: @benchmark_infos %>
-</div>
--- a/web/app/views/results/_results_nav.html.erb	Wed Oct 01 00:13:35 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-<%= content_for :results_navigation do %>
-  <div class="span3 well">
-    <ul class="nav nav-list">
-      <% all_languages.each do |lang| %>
-        <li class="nav-header"><%= lang.name %></li>
-        <ul class="nav nav-list">
-          <% lang.runtimes.each do |runtime| %>
-            <ul class="nav nav-list">
-              <li class="nav-header"><%= runtime.name %></li>
-              <ul class="nav nav-list">
-                <% runtime.benchmark_configurations.each do |benchmark_configuration| %>
-                  <%= nav_tab(benchmark_configuration.id, 
-                              current_tab: current_tab, 
-                              class: "special") do
-                                link_to(benchmark_configuration.operating_system.name_normalized, 
-                                        configuration_results_path(id: benchmark_configuration.id)) 
-                              end %>
-                <% end %>
-              </ul>
-            </ul>
-          <% end %>
-        </ul>
-      <% end %>
-    </ul>
-  </div>
-<% end %>
--- a/web/app/views/results/configuration_results.html.erb	Wed Oct 01 00:13:35 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-<%= currently_viewing_results_of @benchmark_configuration.name %>
-
-<h1><%= @benchmark_configuration.language.name %></h1>
-<h2><%= @benchmark_configuration.runtime.name %>, <%= @benchmark_configuration.operating_system.name_normalized %></h2>
-
-<div id="results-accordion" class="accordion">
-
-  <%= render 'index/timeline_table', benchmark_configuration: @benchmark_configuration %>
-
-  <% @benchmark_configuration.benchmark_batches.reverse.each do |result| %>
-
-    <div class="accordion-group">
-      <div class="accordion-heading">
-        <div class="accordion-toggle">
-        <%= link_to l(result.performed_at),
-          "#result_#{result.id}",
-          'data-toggle' => "collapse",
-          'data-parent' => "#results-accordion" %>
-        <%= link_to('[json]', archive_path(result.id, format: 'json') , 'class' => 'data-download') %>
-        </dib>
-      </div>
-      <%= content_tag :div,
-        id: "result_#{result.id}",
-        class: "accordion-body collapse" do %>
-        <div class="accordion-inner">
-          <%= render 'index/benchmarks_table', results: result %>
-        </div>
-      <% end %>
-    </div>
-
-  <% end %>
-</div>
--- a/web/app/views/results/index.html.erb	Wed Oct 01 00:13:35 2014 +0100
+++ b/web/app/views/results/index.html.erb	Mon Oct 13 10:23:12 2014 +0100
@@ -1,4 +1,52 @@
-<%= currently_viewing_results_of "nothing" %>
+<div class="well">
+    <%= form_for @results_filter,
+      method: 'get',
+      url: results_path,
+      builder: CalipelFormBuilder do | f | %>
+      <%= f.fieldset_item "Configurations" do %>
+        <%= f.checkboxes_item :benchmark_configurations, benchmark_configurations_options %>
+      <% end %>
+      <%= f.fieldset_item "Tags" do %>
+        <%= f.checkboxes_item :tags, tags_options %>
+      <% end %>
+      <%= f.submit_item "Show Results" %>
+    <% end %>
+</div>
+
+
+<div id="results-accordion" class="accordion">
+  <!--
+  < % = render 'index/timeline_table', benchmark_configuration: @benchmark_configuration %>
+  -->
+  <% @results_filter.filtered_results().reverse.each do |result| %>
 
-<h1>Benchmark Results</h1>
-<p>Select language runtime from the left panel</p>
+    <div class="accordion-group">
+      <div class="accordion-heading">
+        <div class="accordion-toggle">
+        <span class="column30">
+          <%= link_to l(result.performed_at),
+            "#result_#{result.id}",
+            'data-toggle' => "collapse",
+            'data-parent' => "#results-accordion" %>
+        </span>
+        <span class="column40">
+          <%= result.benchmark_configuration.name %>
+        </span>
+        <span class="column20">
+          <%= result.tags.map(&:name).join(", ") %>
+        </span>
+        <span class="column05" style="text-align: right">
+          <%= link_to('[json]', archive_path(result.id, format: 'json')) %>
+        </span>
+        </div>
+      </div>
+      <%= content_tag :div,
+        id: "result_#{result.id}",
+        class: "accordion-body collapse" do %>
+        <div class="accordion-inner">
+          <%= render 'index/benchmarks_table', results: result %>
+        </div>
+      <% end %>
+    </div>
+  <% end %>
+</div>
\ No newline at end of file