Started adding results

This commit is contained in:
Gregory Ballantine 2024-02-24 01:34:32 -05:00
parent 65fc2b753b
commit 6761aaa413
5 changed files with 122 additions and 6 deletions

View File

@ -15,6 +15,14 @@ body{
background: #eee;
}
a{
color: teal;
transition: all 200ms ease-in-out;
}
a:hover{
color: #007070;
}
textarea{
max-width: 100%;
min-width: 100%;
@ -25,6 +33,10 @@ textarea{
max-width: 1024px;
}
select[multiple]{
min-height: 125px;
}
#main-nav{
position: fixed;
top: 0;
@ -81,3 +93,10 @@ textarea{
margin-bottom: 5px;
text-align: center;
}
#result_form{
margin-bottom: 0;
}
#result_form *{
margin-bottom: 0;
}

View File

@ -8,6 +8,7 @@ const sequelize = new Sequelize({
const Hardware = require('./hardware')(sequelize);
const Benchmark = require('./benchmark')(sequelize);
const Test = require('./test')(sequelize);
const Result = require('./result')(sequelize);
// Hardware/Test one-to-many
Hardware.hasMany(Test);
@ -17,4 +18,12 @@ Test.belongsTo(Hardware);
Benchmark.belongsToMany(Test, { through: 'tests_benchmarks' });
Test.belongsToMany(Benchmark, { through: 'tests_benchmarks' });
// Result/Benchmark many-to-one
Result.belongsTo(Benchmark);
Benchmark.hasMany(Result);
// Result/Test many-to-one
Result.belongsTo(Test);
Test.hasMany(Result);
module.exports = sequelize;

22
src/models/result.js Normal file
View File

@ -0,0 +1,22 @@
const { Sequelize } = require("sequelize");
module.exports = (sequelize) => {
const Result = sequelize.define('Result', {
avgScore: {
type: Sequelize.DOUBLE,
null: false,
},
minScore: {
type: Sequelize.DOUBLE,
null: true,
},
maxScore: {
type: Sequelize.DOUBLE,
null: true,
}
},
{
tableName: 'results'
});
return Result;
};

View File

@ -9,7 +9,7 @@ exports.getIndex = async function(req, res) {
// GET /test/list - list of tests
exports.getList = async function(req, res) {
var tests = await Test.findAll();
var tests = await Test.findAll({order: [['updatedAt', 'DESC']]});
res.render('test/list', {
tests: tests
});

View File

@ -5,13 +5,79 @@
{% block content %}
<div class="row">
<h2>Test: {{ test.getHardware().name }} - {{ test.dateTag }}</h2>
</div>
<div class="twelve columns">
<ul>
<hr>
<div class="row">
<form id="result_form" class="twelve columns" action="/result/add" method="post">
<input type="hidden" name="result_test" value="{{ test.id }}">
<div class="row">
<div class="four columns">
<label for="result_benchmark">
Benchmark:
<select class="u-full-width" id="result_benchmark" name="result_benchmark">
{% for b in test.getBenchmarks() %}
<li>{{ b.name }}</li>
<option value="{{ b.id }}">{{ b.name }}</option>
{% endfor %}
</ul>
</select>
</label>
</div>
<div class="two columns">
<label for="result_avg">
Average:
<input type="number" id="result_avg" class="u-full-width" name="result_avg">
</label>
</div>
<div class="two columns">
<label for="result_min">
Minimum:
<input type="number" id="result_min" class="u-full-width" name="result_min">
</label>
</div>
<div class="two columns">
<label for="result_max">
Maximum:
<input type="number" id="result_max" class="u-full-width" name="result_max">
</label>
</div>
<input type="submit" class="two columns" value="Submit">
</div>
</form>
</div>
<hr>
<div class="row">
<div class="twelve columns">
<h3>Benchmarks</h3>
<table class="u-full-width">
<thead>
<tr>
<td>Benchmark</td>
<td># Results</td>
<td>Avg.</td>
<td>Min.</td>
<td>Max.</td>
</tr>
</thead>
<tbody>
{% for b in test.getBenchmarks() %}
<tr>
<td>{{ b.name }}</td>
<td>{{ test.getResults({where: {testId: test.id}})|length }}</td>
<td>N/a</td>
<td>N/a</td>
<td>N/a</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<hr>