mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
changed colors and added humidity
This commit is contained in:
@@ -15,7 +15,6 @@ router.get('/allsensors', function(req, res, next) {
|
||||
min : {$min : "$temperature"}}},
|
||||
{$sort : {"_id.month" : 1, "_id.day" : 1, "_id.year" : 1}}]).exec(function(err, info){
|
||||
|
||||
console.log(info);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(JSON.stringify(info, null, 4));
|
||||
|
||||
@@ -35,14 +34,14 @@ router.get('/sensorbylocation/year', function(req, res, next) {
|
||||
|
||||
//query finds a entries in a collection based on location and the year specified
|
||||
//they are then grouped by date and sorted by date as well
|
||||
temperature.aggregate([ {$project : {location : 1, temperature : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}},
|
||||
temperature.aggregate([ {$project : {location : 1, temperature : 1, humidity : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}},
|
||||
{$match : {location : loc, year : parseInt(ye)}},
|
||||
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
||||
max : {$max : "$temperature"},
|
||||
min : {$min : "$temperature"}}},
|
||||
min : {$min : "$temperature"},
|
||||
humidity : {$avg : "$humidity"}}},
|
||||
{$sort : {"_id.month" : 1, "_id.day" : 1}}]).exec(function(err, info){
|
||||
|
||||
console.log(info);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(JSON.stringify(info, null, 4));
|
||||
|
||||
@@ -65,14 +64,14 @@ router.get('/sensorbylocation/month', function(req, res, next) {
|
||||
mo = date.getMonth();
|
||||
}
|
||||
|
||||
console.log(ye + "/" + mo);
|
||||
//query finds a entries in a collection based on location and the year specified
|
||||
//they are then grouped by date and sorted by date as well
|
||||
temperature.aggregate([ {$project : {location : 1, temperature : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}},
|
||||
temperature.aggregate([ {$project : {location : 1, temperature : 1, humidity : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}},
|
||||
{$match : {location : loc, year : parseInt(ye), month : parseInt(mo)}},
|
||||
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
||||
max : {$max : "$temperature"},
|
||||
min : {$min : "$temperature"}}},
|
||||
min : {$min : "$temperature"},
|
||||
humidity : {$avg : "$humidity"}}},
|
||||
{$sort : {"_id.day" : 1}}]).exec(function(err, info){
|
||||
|
||||
console.log(info);
|
||||
|
||||
Reference in New Issue
Block a user