Added form to hardware view page for adding test results
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2024-02-09 10:03:27 -05:00
parent f7979cd005
commit e6333b855f
3 changed files with 68 additions and 10 deletions

View File

@ -14,7 +14,7 @@ class GameData < Sinatra::Base
get '/hardware/add' do
erb :'hardware/add', locals: {
title: 'Add Hardware'
title: 'Add Hardware',
}
end
post '/hardware/add' do
@ -27,10 +27,12 @@ class GameData < Sinatra::Base
end
get '/hardware/:hardware_id' do
benchmarks = Benchmark.order(:name).all()
hardware = Hardware.where(id: params[:hardware_id]).first()
erb :'hardware/view', locals: {
title: hardware.name,
hardware: hardware
hardware: hardware,
benchmarks: benchmarks
}
end

View File

@ -29,12 +29,20 @@ class GameData < Sinatra::Base
Result.create(
hardware_id: params[:result_hardware],
benchmark_id: params[:result_benchmark],
score: params[:result_average],
minimum_score: result_minimum,
maximum_score: result_maximum
avg_score: params[:result_average],
min_score: result_minimum,
max_score: result_maximum
)
redirect '/result'
if params.key?(:result_referrer)
if params[:result_referrer] == 'hardware'
redirect "/hardware/#{params[:result_hardware]}"
elsif params[:result_referrer] == 'benchmark'
redirect "/benchmark/#{params[:result_benchmark]}"
end
else
redirect '/result'
end
end
end