”2016-09-01”

This commit is contained in:
Martin Donnelly 2016-09-01 16:45:04 +01:00
parent 3e03f8cf42
commit c5dd4bb9c8
2 changed files with 33 additions and 20 deletions

View File

@ -42,6 +42,21 @@
});
},
getBranch: function(ts) {
const y = ts.getFullYear().toString();
const m = ts.getMonth().toString();
const d = ts.getDate().toString();
if (this.dateTree.hasOwnProperty(y)) {
if (this.dateTree[y].hasOwnProperty(m)) {
return this.dateTree[y][m][d];
} else {
return null;
}
} else {
return null;
}
},
findOccupancy: function(ts) {
/*
Get a branch from the date tree and see if the reduced set of records has a matching timestamp..
@ -49,9 +64,9 @@
var count = 0;
var tsDate = new Date(ts);
var tsMS = tsDate.getTime();
var branch = this.dateTree[tsDate.getFullYear().toString()][tsDate.getMonth().toString()][tsDate.getDate().toString()];
var branch = this.getBranch(tsDate);
if (typeof branch === 'undefined') {
if (typeof branch === 'undefined' || branch === 'null') {
return count;
}
_(branch).each(function(item) {
@ -151,10 +166,10 @@
}, decoder: function(data) {
var _obj = {};
var _data = window.atob(data).split('');
// var _data = window.atob(data).split('');
//var bytes = _data.map(i => i.charCodeAt());
/*
//Var bytes = _data.map(i => i.charCodeAt());
/*
_obj.light = parseInt('0x' + ('0' + bytes[0]).substr(-2) + ('0' + bytes[1]).substr(
-2));
_obj.co2 = parseInt(_data[2] + _data[3] + _data[4] + _data[5] + _data[6],

View File

@ -19,15 +19,13 @@ var cn = {
// ElephantSql settings
/*
var cn = {
/*var cn = {
host: 'jumbo.db.elephantsql.com',
port: 5432,
database: 'amlrxqev',
user: 'amlrxqev',
password: 'K11cvCplk0--oNafsYj4ISN-rVQmVS3y'
};
*/
};*/
exports.dbConnection = pgp(cn);