Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Commit

Permalink
more performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Cunningham committed Sep 3, 2020
1 parent 4de0434 commit 076a2dd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/plugins/openaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 076a2dd

Please sign in to comment.