Added functionality for better tracking of the minimum and maximum fps

This commit is contained in:
Gregory Ballantine 2023-09-08 00:36:40 -06:00
parent 7e38154bc1
commit a1a00d9fe5
3 changed files with 24 additions and 3 deletions

View File

@ -0,0 +1,17 @@
Sequel.migration do
up do
alter_table(:results) do
add_column :type, String, null: false, default: 'fps'
add_column :minimum_score, String
add_column :maximum_score, String
end
end
down do
drop_column :results, :type
drop_column :results, :minimum_score
drop_column :results, :maximum_score
end
end

View File

@ -20,15 +20,19 @@ class GameData < Sinatra::Base
end end
post '/result/add' do post '/result/add' do
benchmark = Benchmark.where(:id => params[:result_benchmark]).first() benchmark = Benchmark.where(:id => params[:result_benchmark]).first()
formatted_score = params[:result_average]
if benchmark.scoring == 'fps' if benchmark.scoring == 'fps'
formatted_score = params[:result_average] + ':' + params[:result_minimum] + ':' + params[:result_maximum] formatted_score = params[:result_average] + ':' + params[:result_minimum] + ':' + params[:result_maximum]
end end
result_minimum = params[:result_minimum] if params.has_key?(:result_minimum)
result_maximum = params[:result_maximum] if params.has_key?(:result_maximum)
result = Result.create( result = Result.create(
hardware_id: params[:result_hardware], hardware_id: params[:result_hardware],
benchmark_id: params[:result_benchmark], benchmark_id: params[:result_benchmark],
score: formatted_score score: params[:result_average],
minimum_score: result_minimum,
maximum_score: result_maximum
) )
redirect "/result" redirect "/result"

View File

@ -35,7 +35,7 @@
<div class="cell medium-4"> <div class="cell medium-4">
<label> <label>
Average score: Average score:
<input type="number" name="result_average" value="0.0" step="0.01"> <input type="number" name="result_average" value="0.0" step="0.01" required>
</label> </label>
</div> </div>