Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/api/activity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ function configure(app, wares, ctx) {

var d2 = null;

if (t.hasOwnProperty('created_at')) {
if (Object.prototype.hasOwnProperty.call(t, 'created_at')) {
d2 = new Date(t.created_at);
} else {
if (t.hasOwnProperty('timestamp')) {
if (Object.prototype.hasOwnProperty.call(t, 'timestamp')) {
d2 = new Date(t.timestamp);
}
}

if (d2 == null) { return; }

if (d1 == null || d2.getTime() > d1.getTime()) {
if (d1 == null || d2.getTime() > d1.getTime()) {
d1 = d2;
}
});
Expand All @@ -80,7 +80,7 @@ function configure(app, wares, ctx) {

if (!_isArray(activity)) {
activity = [activity];
};
}

ctx.activity.create(activity, function(err, created) {
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions lib/api/alexa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function configure (app, wares, ctx, env) {
});
}, 'BG Status');

ctx.alexa.configureIntentHandler('MetricNow', function (callback, slots, sbx, locale) {
ctx.alexa.configureIntentHandler('MetricNow', function (callback, slots, sbx) {
entries.list({count: 1}, function(err, records) {
var direction;
if(translate(records[0].direction)){
Expand All @@ -121,7 +121,7 @@ function configure (app, wares, ctx, env) {
});
}, ['bg', 'blood glucose', 'number']);

ctx.alexa.configureIntentHandler('MetricNow', function (callback, slots, sbx, locale) {
ctx.alexa.configureIntentHandler('MetricNow', function (callback, slots, sbx) {
if (sbx.properties.delta && sbx.properties.delta.display) {
entries.list({count: 2}, function(err, records) {
callback(
Expand Down
2 changes: 1 addition & 1 deletion lib/api/devicestatus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function configure (app, wares, ctx, env) {
api.delete('/devicestatus/', ctx.authorization.isPermitted('api:devicestatus:delete'), delete_records);
}

if (app.enabled('api') || true /*TODO: auth disabled for quick UI testing...*/ ) {
if (app.enabled('api')) {
config_authed(app, api, wares, ctx);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/api/googlehome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function configure (app, wares, ctx, env) {
});
}, 'BG Status');

ctx.googleHome.configureIntentHandler('MetricNow', function (callback, slots, sbx, locale) {
ctx.googleHome.configureIntentHandler('MetricNow', function (callback, slots, sbx) {
entries.list({count: 1}, function(err, records) {
var direction;
if(translate(records[0].direction)){
Expand All @@ -104,7 +104,7 @@ function configure (app, wares, ctx, env) {
});
}, ['bg', 'blood glucose', 'number']);

ctx.googleHome.configureIntentHandler('MetricNow', function (callback, slots, sbx, locale) {
ctx.googleHome.configureIntentHandler('MetricNow', function (callback, slots, sbx) {
if (sbx.properties.delta && sbx.properties.delta.display) {
entries.list({count: 2}, function(err, records) {
callback(
Expand Down
2 changes: 1 addition & 1 deletion lib/api/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function configure (app, wares, env, ctx) {
// Status badge/text/json
api.get('/status', function (req, res) {

var authToken = req.query.token || req.query.secret || '';
var authToken = req.query.token || req.query.secret || '';

var date = new Date();
var info = { status: 'ok'
Expand Down
6 changes: 3 additions & 3 deletions lib/api/treatments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function configure (app, wares, ctx, env) {

var d2 = null;

if (t.hasOwnProperty('created_at')) {
if (Object.prototype.hasOwnProperty.call(t, 'created_at')) {
d2 = new Date(t.created_at);
} else {
if (t.hasOwnProperty('timestamp')) {
if (Object.prototype.hasOwnProperty.call(t, 'timestamp')) {
d2 = new Date(t.timestamp);
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ function configure (app, wares, ctx, env) {

if (!_isArray(treatments)) {
treatments = [treatments];
};
}

ctx.treatments.create(treatments, function(err, created) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function configure (env, ctx) {

app.get('/version', require('./specific/version')(app, ctx, env));

if (app.get('env') === 'development' || app.get('ci')) { // for development and testing purposes only
if (app.get('env') === 'development' || app.get('ci')) { // for development and testing purposes only
app.get('/test', async function test (req, res) {

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/authorization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function init (env, ctx) {
authorization.isPermitted = function isPermitted (permission, opts) {


opts = mkopts(opts);
mkopts(opts);
authorization.seenPermissions = _.chain(authorization.seenPermissions)
.push(permission)
.sort()
Expand Down
6 changes: 3 additions & 3 deletions lib/authorization/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function init (env, ctx) {

function create (collection) {
function doCreate(obj, fn) {
if (!obj.hasOwnProperty('created_at')) {
if (!Object.prototype.hasOwnProperty.call(obj, 'created_at')) {
obj.created_at = (new Date()).toISOString();
}
collection.insert(obj, function (err, doc) {
Expand Down Expand Up @@ -211,14 +211,14 @@ function init (env, ctx) {
if (!accessToken) return null;

var split_token = accessToken.split('-');
var prefix = split_token ? _.last(split_token) : '';
var prefix = split_token ? _.last(split_token) : '';

if (prefix.length < 16) {
return null;
}

return _.find(storage.subjects, function matches (subject) {
return subject.accessTokenDigest.indexOf(accessToken) === 0 || subject.digest.indexOf(prefix) === 0;
return subject.accessTokenDigest.indexOf(accessToken) === 0 || subject.digest.indexOf(prefix) === 0;
});
};

Expand Down
2 changes: 0 additions & 2 deletions lib/client/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,6 @@ function init (client, d3, $) {
// on the number of hours the user has selected to show
var forecastMills = Math.min(availForecastMills, maxForecastMills);

var lastSGVMills = client.sbx.lastSGVMills();

// Don't allow the forecast time to go below the minimum forecast time
client.forecastTime = Math.max(forecastMills, minForecastMills);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/data/calcdelta.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = function calcDelta (oldData, newData) {
var result = [];
l = newArray.length;
for (var j = 0; j < l; j++) {
if (!seen.hasOwnProperty(newArray[j].mills)) {
if (!Object.prototype.hasOwnProperty.call(seen, newArray[j].mills)) {
result.push(newArray[j]);
}
}
Expand All @@ -94,12 +94,12 @@ module.exports = function calcDelta (oldData, newData) {
var changesFound = false;

for (var array in compressibleArrays) {
if (compressibleArrays.hasOwnProperty(array)) {
if (Object.prototype.hasOwnProperty.call(compressibleArrays, array)) {
var a = compressibleArrays[array];
if (newData.hasOwnProperty(a)) {
if (Object.prototype.hasOwnProperty.call(newData, a)) {

// if previous data doesn't have the property (first time delta?), just assign data over
if (!oldData.hasOwnProperty(a)) {
if (!Object.prototype.hasOwnProperty.call(oldData, a)) {
delta[a] = newData[a];
changesFound = true;
continue;
Expand All @@ -125,9 +125,9 @@ module.exports = function calcDelta (oldData, newData) {
var changesFound = false;

for (var object in skippableObjects) {
if (skippableObjects.hasOwnProperty(object)) {
if (Object.prototype.hasOwnProperty.call(skippableObjects, object)) {
var o = skippableObjects[object];
if (newData.hasOwnProperty(o)) {
if (Object.prototype.hasOwnProperty.call(newData, o)) {
if (JSON.stringify(newData[o]) !== JSON.stringify(oldData[o])) {
//console.log('delta changes found on', o);
changesFound = true;
Expand Down
1 change: 0 additions & 1 deletion lib/data/dataloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ function loadActivity(ddata, ctx, callback) {
}
};

var activity = [];
ctx.activity.list(q, function(err, results) {

if (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/express-extension-to-accept.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (formats) {
throw new Error('Invalid format.')
})

var regexp = new RegExp('\.(' + formats.join('|') + ')$', 'i')
var regexp = new RegExp('.(' + formats.join('|') + ')$', 'i')

return function (req, res, next) {
var match = req.path.match(regexp)
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function extensions (list) {
return require('./express-extension-to-accept')(list);
}

function configure (env) {
function configure () {
return {
sendJSONStatus: wares.sendJSONStatus( ),
bodyParser: wares.bodyParser,
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/alexa.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var _ = require('lodash');
var async = require('async');

function init (env, ctx) {
function init () {
console.log('Configuring Alexa...');
function alexa() {
return alexa;
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/googlehome.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var _ = require('lodash');
var async = require('async');

function init (env, ctx) {
function init () {
console.log('Configuring Google Home...');
function googleHome() {
return googleHome;
Expand Down
6 changes: 0 additions & 6 deletions lib/server/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,9 @@ function init (env, ctx, server) {
socketAuthorization = authorization;
clientType = message.client;
history = message.history || 48; //default history is 48 hours
var from = message.from;

if (socketAuthorization.read) {
socket.join('DataReceivers');
var msecHistory = times.hours(history).msecs;
// if `from` is received, it's a reconnection and full data is not needed
if (from && from > 0) {
msecHistory = Math.min(new Date().getTime() - from, msecHistory);
}

if (lastData && lastData.dataWithRecentStatuses) {
let data = lastData.dataWithRecentStatuses();
Expand Down