adejs/controllers/total/views.js

32 lines
757 B
JavaScript
Raw Normal View History

2017-09-24 00:38:12 +02:00
const cal = require('./calendar');
module.exports.total = function(req, res, render) {
cal.getTotal(req.session.user, (table) => {
let courses = [];
let total = {
name: "Total",
2017-09-24 00:39:13 +02:00
type: "",
2017-09-24 00:38:12 +02:00
time: 0,
tdEquivalent: 0,
}
for (let key in table) {
courses.push({
name: key,
type: table[key].type,
time: table[key].time,
tdEquivalent: table[key].tdEquivalent,
});
total.time += table[key].time;
total.tdEquivalent += table[key].tdEquivalent;
}
res.locals.courses = courses;
res.locals.total = total;
render('total.pug');
});
}