Added views and routes for benchmarks
This commit is contained in:
42
src/routes/benchmark.js
Normal file
42
src/routes/benchmark.js
Normal 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');
|
||||
};
|
Reference in New Issue
Block a user