Added views and routes for benchmarks

This commit is contained in:
2023-11-27 00:42:42 -05:00
parent 2f016d3062
commit 34faecc52c
6 changed files with 138 additions and 1 deletions

42
src/routes/benchmark.js Normal file
View File

@ -0,0 +1,42 @@
const Benchmark = require('../models').models.Benchmark;
// GET /benchmark - redirects to benchmark list
exports.getIndex = async function(req, res) {
res.redirect('/benchmark/list');
};
// GET /benchmark/list - list of benchmarks
exports.getList = async function(req, res) {
var benchmarks = await Benchmark.findAll();
res.render('benchmark/list', {
benchmarks: benchmarks
});
};
// GET /benchmark/:benchmark_id - view information about a benchmark
exports.getView = async function(req, res) {
var benchmark = await Benchmark.findAll({
where: {
id: req.params.benchmark_id
}
});
res.render('benchmark/view', {
benchmark: benchmark[0]
});
};
// GET /benchmark/add - add a new benchmark
exports.getAdd = async function(req, res) {
res.render('benchmark/add');
};
// POST /benchmark/add - add the benchmark to the database
exports.postAdd = async function(req, res) {
var benchmark = await Benchmark.create({
name: req.body.benchmark_name,
scoring: req.body.benchmark_scoring,
description: req.body.benchmark_description
});
res.redirect('/benchmark');
};