diff --git a/lib/client/index.js b/lib/client/index.js index c7487c6b410..ce8efa92f38 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -405,7 +405,6 @@ client.load = function load (serverSettings, callback) { function updateBolusRenderOver () { var bolusRenderOver = (client.settings.bolusRenderOver || 1) + ' U and Over'; $('#bolusRenderOver').text(bolusRenderOver); - console.log('here'); } function alarmingNow () { @@ -434,7 +433,7 @@ client.load = function load (serverSettings, callback) { brushExtent = brushedRange.map(chart.xScale2.invert); } - console.log('brushed(): Brushed to: ', brushExtent); + // console.log('brushed(): Brushed to: ', brushExtent); if (!brushedRange || (brushExtent[1].getTime() - brushExtent[0].getTime() !== client.focusRangeMS)) { // ensure that brush updating is with the time range diff --git a/lib/plugins/openaps.js b/lib/plugins/openaps.js index 59af42c0e61..037680960d2 100644 --- a/lib/plugins/openaps.js +++ b/lib/plugins/openaps.js @@ -123,12 +123,42 @@ function init (ctx) { } function toMoments (status) { + var enacted = false; + var notEnacted = false; + if (status.openaps.enacted && status.openaps.enacted.timestamp && (status.openaps.enacted.recieved || status.openaps.enacted.received)) { + if (status.openaps.enacted.mills) { + enacted = moment(status.openaps.enacted.mills); + } else { + enacted = moment(status.openaps.enacted.timestamp); + } + } else if (status.openaps.enacted && status.openaps.enacted.timestamp && !(status.openaps.enacted.recieved || status.openaps.enacted.received)) { + if (status.openaps.enacted.mills) { + notEnacted = moment(status.openaps.enacted.mills) + } else { + notEnacted = moment(status.openaps.enacted.timestamp) + } + } + + var suggested = false; + if (status.openaps.suggested && status.openaps.suggested.mills) { + suggested = moment(status.openaps.suggested.mills); + } else if (status.openaps.suggested && status.openaps.suggested.timestamp) { + suggested = moment(status.openaps.suggested.timestamp); + } + + var iob = false; + if (status.openaps.iob && status.openaps.iob.mills) { + iob = moment(status.openaps.iob.mills); + } else if (status.openaps.iob && status.openaps.iob.timestamp) { + iob = moment(status.openaps.iob.timestamp); + } + return { when: moment(status.mills) - , enacted: status.openaps.enacted && status.openaps.enacted.timestamp && (status.openaps.enacted.recieved || status.openaps.enacted.received) && moment(status.openaps.enacted.timestamp) - , notEnacted: status.openaps.enacted && status.openaps.enacted.timestamp && !(status.openaps.enacted.recieved || status.openaps.enacted.received) && moment(status.openaps.enacted.timestamp) - , suggested: status.openaps.suggested && status.openaps.suggested.timestamp && moment(status.openaps.suggested.timestamp) - , iob: status.openaps.iob && status.openaps.iob.timestamp && moment(status.openaps.iob.timestamp) + , enacted + , notEnacted + , suggested + , iob }; } @@ -175,7 +205,11 @@ function init (ctx) { var enacted = status.openaps && status.openaps.enacted; if (enacted && moments.enacted && (!result.lastEnacted || moments.enacted.isAfter(result.lastEnacted.moment))) { - enacted.moment = moment(enacted.timestamp); + if (enacted.mills) { + enacted.moment = moment(enacted.mills); + } else { + enacted.moment = moment(enacted.timestamp); + } result.lastEnacted = enacted; if (enacted.predBGs && (!result.lastPredBGs || enacted.moment.isAfter(result.lastPredBGs.moment))) { result.lastPredBGs = _.isArray(enacted.predBGs) ? { values: enacted.predBGs } : enacted.predBGs; @@ -184,13 +218,21 @@ function init (ctx) { } if (enacted && moments.notEnacted && (!result.lastNotEnacted || moments.notEnacted.isAfter(result.lastNotEnacted.moment))) { - enacted.moment = moment(enacted.timestamp); + if (enacted.mills) { + enacted.moment = moment(enacted.mills); + } else { + enacted.moment = moment(enacted.timestamp); + } result.lastNotEnacted = enacted; } var suggested = status.openaps && status.openaps.suggested; if (suggested && moments.suggested && (!result.lastSuggested || moments.suggested.isAfter(result.lastSuggested.moment))) { - suggested.moment = moment(suggested.timestamp); + if (suggested.mills) { + suggested.moment = moment(suggested.mills); + } else { + suggested.moment = moment(suggested.timestamp); + } result.lastSuggested = suggested; if (suggested.predBGs && (!result.lastPredBGs || suggested.moment.isAfter(result.lastPredBGs.moment))) { result.lastPredBGs = _.isArray(suggested.predBGs) ? { values: suggested.predBGs } : suggested.predBGs;