Added rudimentary chart generation for benchmarks
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -4,3 +4,4 @@ require_relative 'index'
|
||||
require_relative 'hardware'
|
||||
require_relative 'benchmark'
|
||||
require_relative 'result'
|
||||
require_relative 'reports'
|
||||
|
46
src/routes/reports.rb
Normal file
46
src/routes/reports.rb
Normal file
@ -0,0 +1,46 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# /reports routes
|
||||
class GameData < Sinatra::Base
|
||||
|
||||
get '/reports' do
|
||||
benchmarks = Benchmark.order(:name).all()
|
||||
hardware = Hardware.order(:name).all()
|
||||
|
||||
erb :'reports/index', locals: {
|
||||
title: 'Generate Reports',
|
||||
hardware: hardware,
|
||||
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|
|
||||
hrd = Hardware.where(id: c).first()
|
||||
names.push(hrd.name)
|
||||
|
||||
res = Result.where(benchmark_id: report_choice, hardware_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
|
Reference in New Issue
Block a user