Removed Test object to simplify database schema; updated docker scripts to run database migrations before starting the server if the database doesn't exist
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2024-02-09 08:40:34 -05:00
parent c83d517437
commit ef2e0a12a5
17 changed files with 17 additions and 274 deletions

View File

@ -3,6 +3,6 @@
# Benchmark - database model for PC benchmarks
class Benchmark < Sequel::Model
one_to_many :tests
one_to_many :results
end

View File

@ -3,6 +3,6 @@
# Hardware - database model for PC hardware
class Hardware < Sequel::Model(:hardware)
one_to_many :tests
one_to_many :results
end

View File

@ -3,4 +3,3 @@
require_relative 'hardware'
require_relative 'benchmark'
require_relative 'result'
require_relative 'test'

View File

@ -3,7 +3,8 @@
# Result - database model for benchmark results
class Result < Sequel::Model
many_to_one :test
many_to_one :hardware
many_to_one :benchmarks
def formatted_score
return @score

View File

@ -1,30 +0,0 @@
# frozen_string_literal: true
# Test - database model for PC hardware tests
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
# formats the name of the test for display in the web UI
def formatted_name
return "#{@date_tag} - #{@hardware.name} / #{@benchmark.name}"
end
# formats the name of the test for use in a graph
def graph_name
return "#{@hardware.name} (#{@date_tag})"
end
# determines whether the test has enough results to fulfill the requirement
def valid?
return (@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') - @results.length)
end
end

View File

@ -4,12 +4,10 @@
class GameData < Sinatra::Base
get '/' do
tests = Test.reverse(:updated_at).limit(10).all()
results = Result.reverse(:updated_at).limit(10).all()
erb :'index/index', locals: {
title: 'Dashboard',
tests: tests,
results: results
}
end

View File

@ -4,4 +4,3 @@ require_relative 'index'
require_relative 'hardware'
require_relative 'benchmark'
require_relative 'result'
require_relative 'test'

View File

@ -1,53 +0,0 @@
# frozen_string_literal: true
# /test routes
class GameData < Sinatra::Base
get '/test' do
tests = Test.reverse(:updated_at).limit(10).all()
erb :'test/index', locals: {
title: 'List of Tests',
tests: tests
}
end
get '/test/add' do
hardware = Hardware.all()
benchmarks = Benchmark.all()
erb :'test/add', locals: {
title: 'Add Test',
hardware: hardware,
benchmarks: benchmarks
}
end
post '/test/add' do
date_tag = params[:test_date_tag]
# make sure the date tag field is formatting properly
date_tag = "(#{date_tag}" unless date_tag.start_with?('(')
date_tag += ')' unless date_tag.end_with?(')')
test = Test.create(
date_tag: date_tag,
hardware_id: params[:test_hardware]
)
params[:test_benchmarks].each do |b|
benchmark = Benchmark.where(id: b).first()
test.add_benchmark(benchmark)
end
redirect "/test/#{test.id}"
end
get '/test/:test_id' do
test = Test.where(id: params[:test_id]).first()
erb :'test/view', locals: {
title: "Test: #{test.date_tag}",
test: test
}
end
end