Files
game-data/src/routes/reports.rb
T
gballan aec77628f7
ci/woodpecker/push/woodpecker Pipeline failed
Small updates
2025-07-23 23:25:00 -04:00

47 lines
1.0 KiB
Ruby

# frozen_string_literal: true
# /reports routes
class GameData < Sinatra::Base
get '/reports' do
benchmarks = Benchmark.order(:name).all()
tests = Test.order(:name).all()
erb :'reports/index', locals: {
title: 'Generate Reports',
tests: tests,
benchmarks: benchmarks
}
end
post '/reports' do
report_type = params[:type]
report_choice = params[:choice]
report_compare = params[:compare]
if report_type == 'benchmark'
choice = Benchmark.where(id: report_choice).first().name
names = []
avg_results = []
min_results = []
report_compare.each do |c|
tst = Test.where(id: c).first()
names.push(tst.name)
res = Result.where(benchmark_id: report_choice, test_id: c).first()
avg_results.push(res.avg_score)
min_results.push(res.min_score)
end
json({
choice: choice,
names: names,
avg_results: avg_results,
min_results: min_results
})
end
end
end