Skip to content

Commit 076a2dd

Browse files
author
Jeremy Cunningham
committed
more performance improvements
1 parent 4de0434 commit 076a2dd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/plugins/openaps.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ function init (ctx) {
205205

206206
var enacted = status.openaps && status.openaps.enacted;
207207
if (enacted && moments.enacted && (!result.lastEnacted || moments.enacted.isAfter(result.lastEnacted.moment))) {
208-
enacted.moment = moment(enacted.timestamp);
208+
if (enacted.mills) {
209+
enacted.moment = moment(enacted.mills);
210+
} else {
211+
enacted.moment = moment(enacted.timestamp);
212+
}
209213
result.lastEnacted = enacted;
210214
if (enacted.predBGs && (!result.lastPredBGs || enacted.moment.isAfter(result.lastPredBGs.moment))) {
211215
result.lastPredBGs = _.isArray(enacted.predBGs) ? { values: enacted.predBGs } : enacted.predBGs;
@@ -214,13 +218,21 @@ function init (ctx) {
214218
}
215219

216220
if (enacted && moments.notEnacted && (!result.lastNotEnacted || moments.notEnacted.isAfter(result.lastNotEnacted.moment))) {
217-
enacted.moment = moment(enacted.timestamp);
221+
if (enacted.mills) {
222+
enacted.moment = moment(enacted.mills);
223+
} else {
224+
enacted.moment = moment(enacted.timestamp);
225+
}
218226
result.lastNotEnacted = enacted;
219227
}
220228

221229
var suggested = status.openaps && status.openaps.suggested;
222230
if (suggested && moments.suggested && (!result.lastSuggested || moments.suggested.isAfter(result.lastSuggested.moment))) {
223-
suggested.moment = moment(suggested.timestamp);
231+
if (suggested.mills) {
232+
suggested.moment = moment(suggested.mills);
233+
} else {
234+
suggested.moment = moment(suggested.timestamp);
235+
}
224236
result.lastSuggested = suggested;
225237
if (suggested.predBGs && (!result.lastPredBGs || suggested.moment.isAfter(result.lastPredBGs.moment))) {
226238
result.lastPredBGs = _.isArray(suggested.predBGs) ? { values: suggested.predBGs } : suggested.predBGs;

0 commit comments

Comments
 (0)