mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-15 03:52:48 +00:00
more graph work
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user