--- a/web/app/helpers/settings/benchmark_configurations_helper.rb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/helpers/settings/benchmark_configurations_helper.rb Tue Nov 17 15:05:38 2015 +0100
@@ -1,7 +1,8 @@
module Settings::BenchmarkConfigurationsHelper
def all_configurations_for(compare_query)
- BenchmarkConfiguration.for_benchmark_infos(compare_query.filtered_benchmark_info_ids)
+ BenchmarkConfiguration
+ .for_benchmark_infos(compare_query.filtered_benchmark_info_ids)
end
def all_configurations_options
--- a/web/app/models/benchmark_info.rb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/models/benchmark_info.rb Tue Nov 17 15:05:38 2015 +0100
@@ -19,11 +19,10 @@
end
def latest_result_for_configuration(configuration)
- benchmark_results.
- for_configuration_id(configuration.id).
- with_batch_and_duration_preloaded.
- newest_first.
- first
+ benchmark_results
+ .select { |r| r.benchmark_batch.benchmark_configuration_id == configuration.id }
+ .sort { |r, s| r.performed_at <=> s.performed_at }
+ .first
end
end
--- a/web/app/models/benchmark_result.rb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/models/benchmark_result.rb Tue Nov 17 15:05:38 2015 +0100
@@ -5,19 +5,6 @@
has_many :benchmark_durations, dependent: :destroy, inverse_of: :benchmark_result
has_many :benchmark_parameters, dependent: :destroy, inverse_of: :benchmark_result
- scope :for_configuration_id, -> (configuration_id) do
- joins(:benchmark_batch).
- where("benchmark_batches.benchmark_configuration_id = ?", configuration_id)
- end
-
- scope :with_batch_and_duration_preloaded, -> do
- includes(:benchmark_batch, :benchmark_durations)
- end
-
- scope :newest_first, -> do
- order("benchmark_batches.performed_at desc, benchmark_batches.created_at desc")
- end
-
def average_duration
sum = benchmark_durations.inject(0) { |acc, val| acc += val.duration }
sum / benchmark_durations.size
--- a/web/app/models/compare_query.rb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/models/compare_query.rb Tue Nov 17 15:05:38 2015 +0100
@@ -10,11 +10,15 @@
end
def filtered_benchmark_infos
- BenchmarkInfo.where(id: filtered_benchmark_info_ids)
+ BenchmarkInfo
+ .where(id: filtered_benchmark_info_ids)
+ .includes(benchmark_results: [ :benchmark_batch,
+ :benchmark_durations,
+ :benchmark_parameters ])
end
def filtered_benchmark_info_ids
- benchmark_infos.compact
+ benchmark_infos.select(&:present?).compact
end
end
--- a/web/app/views/index/_compare_table.html.erb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/views/index/_compare_table.html.erb Tue Nov 17 15:05:38 2015 +0100
@@ -7,21 +7,21 @@
<% benchmark_infos.each_with_index do |benchmark_info, index| %>
<% latest_result = benchmark_info.latest_result_for_configuration(bc) %>
- <div class="chart-bar-value"
- data-index="<%= index %>"
- data-value="<%= latest_result.try(:min_duration) %>">
- </div>
- <div class="chart-bar-labels"
- data-name="<%= benchmark_info.name %>"
- data-index="<%= index %>"
- data-parameters="<%= latest_result.try(:benchmark_parameters_json) %>">
- </div>
+ <div class="chart-bar-value"
+ data-index="<%= index %>"
+ data-value="<%= latest_result.try(:min_duration) %>">
+ </div>
+ <div class="chart-bar-labels"
+ data-name="<%= benchmark_info.name %>"
+ data-index="<%= index %>"
+ data-parameters="<%= latest_result.try(:benchmark_parameters_json) %>">
+ </div>
- <% end %>
- </div>
- <% end %>
+ <% end %>
+ </div>
+ <% end %>
- <div class="chart-legend"></div>
+ <div class="chart-legend"></div>
<div class="chart-container">
<div class="chart-y-axis"></div>
--- a/web/app/views/settings/benchmark_configurations/show.html.erb Tue Nov 17 15:02:56 2015 +0100
+++ b/web/app/views/settings/benchmark_configurations/show.html.erb Tue Nov 17 15:05:38 2015 +0100
@@ -2,7 +2,7 @@
<h1><%= @benchmark_configuration.name %> configuration</h1>
-<%= render 'form',
- benchmark_configuration: @benchmark_configuration,
+<%= render 'form',
+ benchmark_configuration: @benchmark_configuration,
heading: "Edit configuration #{@benchmark_configuration.name}" %>