fix homepage
authorMarcel Hlopko <marcel.hlopko@gmail.com>
Tue, 25 Jun 2013 22:34:55 +0200
changeset 109 01cd7822c1f0
parent 108 69aa849f6930
child 110 02126b7e1cbb
fix homepage
web/app/models/benchmark_configuration.rb
web/app/views/index/_timeline_table.html.erb
web/app/views/index/index.html.erb
--- a/web/app/models/benchmark_configuration.rb	Tue Jun 25 22:30:20 2013 +0200
+++ b/web/app/models/benchmark_configuration.rb	Tue Jun 25 22:34:55 2013 +0200
@@ -9,4 +9,37 @@
     "#{runtime.name} (#{language.name}) on #{operating_system.name}"
   end
 
+  def all_benchmark_infos
+    result = Set.new
+    benchmark_batches.each do |batch|
+      batch.benchmark_results.each { |r| result.add r.benchmark_info }
+    end
+    result
+  end
+
+  def all_dates_when_performed
+    SortedSet.new(benchmark_batches.map(&:performed_at).flatten).to_a
+  end
+
+  def results_at(time)
+    batch = benchmark_batches.where(performed_at: time).first
+    all_benchmark_infos.map do |info|
+      batch.result_for(info)
+    end
+  end
+
+  def results_of(benchmark_info, time)
+    batch_with_given_date = benchmark_batches
+    .where(performed_at: time)
+    .first
+
+    if batch_with_given_date
+      batch_with_given_date
+      .benchmark_results(benchmark_info: benchmark_info)
+      .first
+    else
+      nil
+    end
+  end
+
 end
--- a/web/app/views/index/_timeline_table.html.erb	Tue Jun 25 22:30:20 2013 +0200
+++ b/web/app/views/index/_timeline_table.html.erb	Tue Jun 25 22:34:55 2013 +0200
@@ -5,18 +5,18 @@
       <thead>
         <tr>
           <th>Month</th>
-          <% runtime.all_benchmark_infos.each do |info| %> 
+          <% configuration.all_benchmark_infos.each do |info| %> 
             <th><%= info.name %></th>
           <% end %>
         </tr>
       </thead>
       <tbody>
-        <% all_dates_when_performed(runtime).each do |date| %>
+        <% all_dates_when_performed(configuration).each do |date| %>
           <tr>
             <%= content_tag :th, 
               (make_chart ? date_to_millis(date) : t(date)), 
               'data-timestamp' => date_to_millis(date) %>
-            <% runtime.results_at(date).each do |result| %>
+            <% configuration.results_at(date).each do |result| %>
               <td><%= result.try(:min_duration) %></td>
             <% end %>
           </tr>
--- a/web/app/views/index/index.html.erb	Tue Jun 25 22:30:20 2013 +0200
+++ b/web/app/views/index/index.html.erb	Tue Jun 25 22:34:55 2013 +0200
@@ -11,8 +11,7 @@
 <% if @current_results.present? %>
   <p>
     Showing latest results for 
-    <%= @current_results.runtime.name %> 
-    (<%= @current_results.runtime.language.name %>)
+    <%= @current_results.configuration.name %> 
     performed at
     <%= t @current_results.performed_at %>
   </p>
@@ -23,12 +22,11 @@
 
   <p>
     Showing all results for 
-    <%= @current_results.runtime.name %> 
-    (<%= @current_results.runtime.language.name %>)
+    <%= @current_results.configuration.name %> 
   </p>
 
   <%= render 'timeline_table', 
-    runtime: @current_results.runtime, 
+    configuration: @current_results.configuration, 
     make_chart: true %>
 
 <% end %>