mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* Remove unnecessary logging to help with Papertrail limits
* Load more treatments and entries to fix caching issues (need to add better cache invalidation to really fix this)
This commit is contained in:
+3
-1
@@ -9,5 +9,7 @@
|
||||
"MMOL_TO_MGDL": 18,
|
||||
"ONE_DAY" : 86400000,
|
||||
"TWO_DAYS" : 172800000,
|
||||
"FIFTEEN_MINUTES": 900000
|
||||
"FIFTEEN_MINUTES": 900000,
|
||||
"THREE_HOURS": 10800000,
|
||||
"ONE_HOUR": 3600000
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ function init(env, ctx) {
|
||||
function loadEntries(ddata, ctx, callback) {
|
||||
|
||||
const withFrame = ddata.page && ddata.page.frame;
|
||||
const loadPeriod = ddata.sgvs && ddata.sgvs.length > 0 && !withFrame ? constants.FIFTEEN_MINUTES : constants.TWO_DAYS;
|
||||
const loadPeriod = ddata.sgvs && ddata.sgvs.length > 0 && !withFrame ? constants.ONE_HOUR : constants.TWO_DAYS;
|
||||
const latestEntry = ddata.sgvs && ddata.sgvs.length > 0 ? findLatestMills(ddata.sgvs) : ddata.lastUpdated;
|
||||
|
||||
var dateRange = {
|
||||
@@ -292,7 +292,7 @@ function loadTreatments(ddata, ctx, callback) {
|
||||
// Load 2.5 days to cover last 48 hours including overlapping temp boluses or temp targets for first load
|
||||
// Subsequently load at least 15 minutes of data, but if latest entry is older than 15 minutes, load until that entry
|
||||
|
||||
const loadPeriod = ddata.treatments && ddata.treatments.length > 0 && !withFrame ? constants.FIFTEEN_MINUTES : longLoad;
|
||||
const loadPeriod = ddata.treatments && ddata.treatments.length > 0 && !withFrame ? constants.THREE_HOURS : longLoad;
|
||||
const latestEntry = ddata.treatments && ddata.treatments.length > 0 ? findLatestMills(ddata.treatments) : ddata.lastUpdated;
|
||||
const loadTime = Math.min(ddata.lastUpdated - loadPeriod, latestEntry);
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ function init (env, ctx, server) {
|
||||
|
||||
function emitData (delta) {
|
||||
if (lastData.cals) {
|
||||
console.log(LOG_WS + 'running websocket.emitData', ctx.ddata.lastUpdated);
|
||||
// console.log(LOG_WS + 'running websocket.emitData', ctx.ddata.lastUpdated);
|
||||
if (lastProfileSwitch !== ctx.ddata.lastProfileFromSwitch) {
|
||||
console.log(LOG_WS + 'profile switch detected OLD: ' + lastProfileSwitch + ' NEW: ' + ctx.ddata.lastProfileFromSwitch);
|
||||
// console.log(LOG_WS + 'profile switch detected OLD: ' + lastProfileSwitch + ' NEW: ' + ctx.ddata.lastProfileFromSwitch);
|
||||
delta.status = status(ctx.ddata.profiles);
|
||||
lastProfileSwitch = ctx.ddata.lastProfileFromSwitch;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ function init (env, ctx, server) {
|
||||
socket.emit('dataUpdate', data);
|
||||
}
|
||||
}
|
||||
console.log(LOG_WS + 'Authetication ID: ', socket.client.id, ' client: ', clientType, ' history: ' + history);
|
||||
// console.log(LOG_WS + 'Authetication ID: ', socket.client.id, ' client: ', clientType, ' history: ' + history);
|
||||
if (callback) {
|
||||
callback(socketAuthorization);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ function init (env, ctx, server) {
|
||||
socket.on('nsping', function ping (message, callback) {
|
||||
var clientTime = message.mills;
|
||||
timeDiff = new Date().getTime() - clientTime;
|
||||
console.log(LOG_WS + 'Ping from client ID: ',socket.client.id, ' client: ', clientType, ' timeDiff: ', (timeDiff/1000).toFixed(1) + 'sec');
|
||||
// console.log(LOG_WS + 'Ping from client ID: ',socket.client.id, ' client: ', clientType, ' timeDiff: ', (timeDiff/1000).toFixed(1) + 'sec');
|
||||
if (callback) {
|
||||
callback({ result: 'pong', mills: new Date().getTime(), authorization: socketAuthorization });
|
||||
}
|
||||
@@ -480,14 +480,14 @@ function init (env, ctx, server) {
|
||||
}
|
||||
|
||||
websocket.update = function update ( ) {
|
||||
console.log(LOG_WS + 'running websocket.update');
|
||||
// console.log(LOG_WS + 'running websocket.update');
|
||||
if (lastData.sgvs) {
|
||||
var delta = calcData(lastData, ctx.ddata);
|
||||
if (delta.delta) {
|
||||
console.log('lastData full size', JSON.stringify(lastData).length,'bytes');
|
||||
if (delta.sgvs) { console.log('patientData update size', JSON.stringify(delta).length,'bytes'); }
|
||||
// console.log('lastData full size', JSON.stringify(lastData).length,'bytes');
|
||||
// if (delta.sgvs) { console.log('patientData update size', JSON.stringify(delta).length,'bytes'); }
|
||||
emitData(delta);
|
||||
} else { console.log('delta calculation indicates no new data is present'); }
|
||||
}; // else { console.log('delta calculation indicates no new data is present'); }
|
||||
}
|
||||
lastData = ctx.ddata.clone();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user