1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-15 03:52:48 +00:00

more graph work

This commit is contained in:
2015-12-20 21:11:54 -06:00
parent b33ea2cb7d
commit 5bae9b8af2
7 changed files with 316 additions and 72 deletions

View File

@@ -74,9 +74,30 @@ router.get('/information', function(req, res, err){
if (sensor_location == null){
res.redirect('/404');
}
else{
temperature.aggregate([{$project : {location : "$location", year : {$year : "$updated"}, month : {$month : "$updated"}}},
{$match : {location : sensor_location}},
{$group : {_id : {year : "$year", month : "$month", location : "$location"}}},
{$sort : {"_id.year" : 1, "_id.month" : 1}}]).exec(function(err, info){
console.log(info);
res.render('sensor_information', {info : {location : sensor_location}});
//generate list of unique years to display in dropdown menu
var years_list = [];
for (var i in info){
if (years_list.indexOf(info[i]._id.year) > -1){
}
else {
years_list.push(info[i]._id.year);
}
}
res.render('sensor_information', {info, years_list});
});
}
});
module.exports = router;