”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) { findOccupancy: function(ts) {
/* /*
Get a branch from the date tree and see if the reduced set of records has a matching timestamp.. 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 count = 0;
var tsDate = new Date(ts); var tsDate = new Date(ts);
var tsMS = tsDate.getTime(); 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; return count;
} }
_(branch).each(function(item) { _(branch).each(function(item) {
@ -151,9 +166,9 @@
}, decoder: function(data) { }, decoder: function(data) {
var _obj = {}; 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( _obj.light = parseInt('0x' + ('0' + bytes[0]).substr(-2) + ('0' + bytes[1]).substr(
-2)); -2));

View File

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