const cal = require('./calendar'); module.exports.total = function(req, res, render) { cal.getTotal(req.session.user, (table) => { let courses = []; let total = { name: "Total", type: "", 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'); }); }