Started adding results
This commit is contained in:
@ -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
22
src/models/result.js
Normal 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;
|
||||
};
|
@ -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
|
||||
});
|
||||
|
Reference in New Issue
Block a user