game-data/src/models/test.rb

34 lines
1.0 KiB
Ruby

class Test < Sequel::Model
one_to_many :results # link Test model to its related results
many_to_one :benchmark # link Test model back to its benchmark
many_to_one :hardware # link Test model back to hardware used in test
# many-to-many with Project
many_to_many :projects,
left_id: :project_id,
right_id: :test_id,
join_table: :projects_tests
# formats the name of the test for display in the web UI
def formatted_name()
return "#{self.date_tag} - #{self.hardware.name} / #{self.benchmark.name}"
end
# formats the name of the test for use in a graph
def graph_name()
return "#{self.hardware.name} (#{self.date_tag})"
end
# determines whether the test has enough results to fulfill the requirement
def valid?()
return (self.results.length >= $conf.get('testing.minimum_results_required'))
end
# determines how many results are still missing for a test
def missing_results()
return ($conf.get('testing.minimum_results_required') - self.results.length)
end
end