Changed naming from Routes to Controllers; fixed some Sinatra modular layout stuff; added RSpec for testing and some basic tests
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine
2025-08-12 16:15:43 -04:00
parent 260d0d1268
commit 40cfdcc2a3
18 changed files with 105 additions and 83 deletions

View File

@@ -0,0 +1,53 @@
# frozen_string_literal: true
require 'sinatra/json'
require_relative 'base_controller'
require_relative '../models/benchmark'
require_relative '../models/result'
require_relative '../models/test'
# /reports routes
class ReportsController < BaseController
get '/report' do
benchmarks = Benchmark.order(:name).all()
tests = Test.order(:name).all()
erb :'reports/index', locals: {
title: 'Generate Reports',
tests: tests,
benchmarks: benchmarks
}
end
post '/report' 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