web/app/models/compare_query.rb
author Marcel Hlopko <marcel.hlopko@gmail.com>
Tue, 25 Jun 2013 22:11:10 +0200
changeset 106 eac4098d544d
parent 91 d430a8ac253d
child 111 28dccacb2bc1
permissions -rw-r--r--
huge refactoring to better fit what we agreed on
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     1
class CompareQuery
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     2
  include ActiveModel::Model
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     3
106
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
     4
  attr_accessor :benchmark_id, :runtimes
91
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     5
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     6
  def initialize(*args)
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     7
    super
106
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
     8
    @runtimes ||= {}
91
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
     9
  end
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    10
106
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
    11
  def filtered_runtimes
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
    12
    Runtime.where(id: runtimes_to_array_of_ids)
91
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    13
  end
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    14
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    15
  def benchmark_info
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    16
    BenchmarkInfo.find(benchmark_id)
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    17
  end
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    18
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    19
  private
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    20
106
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
    21
  def runtimes_to_array_of_ids
eac4098d544d huge refactoring to better fit what we agreed on
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 91
diff changeset
    22
    runtimes.keys
91
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    23
  end
d430a8ac253d comparison page kinda works
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
diff changeset
    24
end