From 076a2dd3b69093149994258eb0244ae61d68f44e Mon Sep 17 00:00:00 2001 From: Jeremy Cunningham Date: Thu, 3 Sep 2020 04:08:46 -0500 Subject: [PATCH] more performance improvements --- lib/plugins/openaps.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/plugins/openaps.js b/lib/plugins/openaps.js index 55cd089df86..0f27f952cbd 100644 --- a/lib/plugins/openaps.js +++ b/lib/plugins/openaps.js @@ -205,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; @@ -214,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;