[Issue #5] - Reworked app to better organize results with their corresponding tests
This commit is contained in:
48
src/routes/test.rb
Normal file
48
src/routes/test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
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/:test_id' do
|
||||
test = Test.where(id: params[:test_id]).first()
|
||||
erb :'test/view', locals: {
|
||||
title: "Test: #{test.date_tag}",
|
||||
test: test
|
||||
}
|
||||
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
|
||||
unless date_tag.start_with?('(')
|
||||
date_tag = '(' + date_tag
|
||||
end
|
||||
unless date_tag.end_with?(')')
|
||||
date_tag = date_tag + ')'
|
||||
end
|
||||
|
||||
test = Test.create(
|
||||
date_tag: params[:test_date_tag],
|
||||
hardware_id: params[:test_hardware],
|
||||
benchmark_id: params[:test_benchmark]
|
||||
)
|
||||
|
||||
redirect "/test/#{test.id}"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user