From 6f2b0e7515924c09b39768df98f4f0854716e52c Mon Sep 17 00:00:00 2001 From: Lennart Goedhart Date: Thu, 3 May 2018 18:55:36 +1000 Subject: [PATCH 1/2] Remove exact duplicate SMBGs This can occur for non ClosedLoop SMBGs when a calibration occurs, causing the Daily view SMBG count to be incorrect. --- app/package.json | 2 +- lib/drivers/medtronic600/medtronic600Simulator.js | 13 ++++++++----- package.json | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/package.json b/app/package.json index 6388325cc0..2172118cb4 100755 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "tidepool-uploader", "productName": "tidepool-uploader", - "version": "2.2.5-600series-qa.21", + "version": "2.2.5-600series-qa.22", "description": "Tidepool Project Universal Uploader", "main": "./main.js", "author": { diff --git a/lib/drivers/medtronic600/medtronic600Simulator.js b/lib/drivers/medtronic600/medtronic600Simulator.js index 5267806e02..aba3e63ac8 100644 --- a/lib/drivers/medtronic600/medtronic600Simulator.js +++ b/lib/drivers/medtronic600/medtronic600Simulator.js @@ -282,12 +282,15 @@ class Medtronic600Simulator { smbg(event) { if (this.currSMBG != null && this.currSMBG.value === event.value) { - debug( - 'Duplicate SMBG value (', event.value, ')', this.currSMBG.subType, this.currSMBG.time, - '/', event.subType, event.time, - ); + debug(`Duplicate SMBG value (${event.value}) ${this.currSMBG.subType}: ${this.currSMBG.time} / ${event.subType}: ${event.time}`); const duration = Date.parse(event.time) - Date.parse(this.currSMBG.time); - if ((duration < (15 * sundial.MIN_TO_MSEC)) && (event.subType === 'manual') && + if (_.isEqual(event, this.currSMBG)) { + // The BloodGlucoseReadingEvent event can be sent twice, if the second event + // is a calibration. Since we build calibrations from CalibrationCompleteEvent, + // we can delete the exact duplicate. + debug('Dropping exact duplicate'); + return; + } else if ((duration < (15 * sundial.MIN_TO_MSEC)) && (event.subType === 'manual') && (this.currSMBG.subType === 'linked')) { debug('Dropping duplicate manual value'); return; diff --git a/package.json b/package.json index d9c596b784..b27d831dab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tidepool-uploader", - "version": "2.2.5-600series-qa.21", + "version": "2.2.5-600series-qa.22", "description": "Tidepool Project Universal Uploader", "private": true, "main": "main.js", From 5f5f5050e244be63d351408e59ba29ed02b137d0 Mon Sep 17 00:00:00 2001 From: Lennart Goedhart Date: Thu, 3 May 2018 19:12:57 +1000 Subject: [PATCH 2/2] Update unit tests for manual mode SMBG fix --- test/node/medtronic600/testMedtronic600Simulator.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/node/medtronic600/testMedtronic600Simulator.js b/test/node/medtronic600/testMedtronic600Simulator.js index c65b966fc4..80bedf64cf 100644 --- a/test/node/medtronic600/testMedtronic600Simulator.js +++ b/test/node/medtronic600/testMedtronic600Simulator.js @@ -107,13 +107,11 @@ describe('medtronic600Simulator.js', function() { expect(simulator.getEvents()).deep.equals([linked]); }); - it('should not drop duplicate linked values', function() { + it('should drop exact duplicate linked values', function() { simulator.smbg(linked); simulator.smbg(linked); - const expectedSecond = _.cloneDeep(linked); - - expect(simulator.getEvents()).deep.equals([linked, expectedSecond]); + expect(simulator.getEvents()).deep.equals([linked]); }); });