diff -r 2565b32e93b3 -r 195fca969b9a web/app/models/benchmark_result.rb --- a/web/app/models/benchmark_result.rb Tue Oct 28 17:21:19 2014 +0100 +++ b/web/app/models/benchmark_result.rb Tue Oct 28 17:28:57 2014 +0100 @@ -5,6 +5,18 @@ 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 }