1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 02:12:53 +00:00

updated date on sensors page

This commit is contained in:
2016-01-21 19:29:31 -06:00
parent 467189e4ae
commit 96f67da170

View File

@@ -9,8 +9,9 @@ var temperature = mongoose.model('temperature');
/* GET sensors page. */
router.get('/', function(req, res, next) {
temperature.aggregate( [{ $group : { _id : "$location", temperature : {$last : "$temperature"}, humidity : {$last : "$humidity"}, updated : {$last : "$updated"}}},
{$sort : {location : -1, updated : -1}} ] ).exec(function(err, info){
temperature.aggregate( [{$project : {sDate : {$subtract : ["$updated", 21600000]}}},
{ $group : { _id : "$location", temperature : {$last : "$temperature"}, humidity : {$last : "$humidity"}, updated : {$last : "$sDate"}}},
{$sort : {location : -1, updated : -1}} ] ).exec(function(err, info){
//get month for each entry and convert 24 hour time to US time
//also check to see if device has sent a data point in past 5 minutes