50 lines
1.6 KiB
CoffeeScript
50 lines
1.6 KiB
CoffeeScript
testId = $('#results-table').data('test-id')
|
|
|
|
fetchTestBenchmarkResults = (testId, benchmarkId) ->
|
|
try
|
|
benchmarkSearchParams = new URLSearchParams
|
|
benchmark_id: benchmarkId
|
|
benchmarkRes = await fetch("/api/v1/benchmark/details?#{benchmarkSearchParams}")
|
|
benchmarkData = await benchmarkRes.json()
|
|
|
|
resultSearchParams = new URLSearchParams
|
|
test_id: testId
|
|
benchmark_id: benchmarkId
|
|
resultRes = await fetch("/api/v1/results?#{resultSearchParams}")
|
|
resultData = await resultRes.json()
|
|
|
|
avg_total = 0
|
|
min_total = 0
|
|
max_total = 0
|
|
|
|
for result in resultData
|
|
avg_total += result.avg_score
|
|
min_total += result.min_score
|
|
max_total += result.max_score
|
|
|
|
tableRow = $("#results-table tr[data-benchmark-id=#{benchmarkId}]")
|
|
|
|
tableRow.append('<td>' + benchmarkData.name + '</td>')
|
|
tableRow.append('<td>' + benchmarkData.scoring + '</td>')
|
|
tableRow.append('<td>' + resultData.length + '</td>')
|
|
|
|
if resultData.length != 0
|
|
tableRow.append('<td>' + (avg_total / resultData.length) + '</td>')
|
|
else
|
|
tableRow.append('<td>N/a</td>')
|
|
|
|
if min_total != 0
|
|
tableRow.append('<td>' + (min_total / resultData.length) + '</td>')
|
|
tableRow.append('<td>' + (max_total / resultData.length) + '</td>')
|
|
else
|
|
tableRow.append('<td>N/a</td>')
|
|
tableRow.append('<td>N/a</td>')
|
|
catch error
|
|
console.error 'An error occurred while fetching benchmark results.', error
|
|
|
|
$('#results-table tbody tr').each((index, tr) ->
|
|
benchmarkId = $(tr).data('benchmark-id')
|
|
console.log("Fetching results for benchmark id: " + benchmarkId)
|
|
fetchTestBenchmarkResults(testId, benchmarkId)
|
|
)
|