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

fixed updated date - adjusted sensor page for humidity - updated mongoose model for temperature

This commit is contained in:
2016-01-24 19:51:12 -06:00
parent 5c306cac56
commit a3f86e8a7e
3 changed files with 12 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
var mongoose = require('mongoose');
var temperatureSchema = new mongoose.Schema({
temperature: Number,
humidity: Number,
temperature: {type : Number, default : null},
humidity: {type : Number, default : null},
location: {type : String, default : "Undefined Location"},
updated: {type: Date, default: Date.now}
});

View File

@@ -10,7 +10,8 @@ var temperature = mongoose.model('temperature');
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){
{$sort : {_id : -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
@@ -22,8 +23,8 @@ router.get('/', function(req, res, next) {
var hours = info[i].updated.getHours();
var minutes = info[i].updated.getMinutes();
var month = monthNames[info[i].updated.getMonth()];
var date = info[i].updated.getUTCDate();
var year = info[i].updated.getUTCFullYear();
var date = info[i].updated.getDate();
var year = info[i].updated.getFullYear();
var dateString = month + " " + date + ", " + year;

View File

@@ -25,7 +25,11 @@ I will continue to investigate this problem when I can get my hands on the senso
<div class="col-lg-4">
<h3><%=query[i]._id%></h3>
<h4>Temperature: <%=query[i].temperature%>°F </h4>
<% if (query[i].humidity != null) { %>
<h4>Humidity: <%=query[i].humidity%>%</h4>
<%}%>
<span>Updated: <%=query[i].lastUpdate%></span>
<br>
<% if (query[i].connected){ %>