Skip to content

Commit

Permalink
Merge pull request tidepool-org#610 from tidepool-org/pazaan/medtroni…
Browse files Browse the repository at this point in the history
…c600-manual-mode-smbg-fix

Remove exact duplicate SMBGs
  • Loading branch information
pazaan authored May 3, 2018
2 parents 0f97866 + 6d24c32 commit d20a068
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
13 changes: 8 additions & 5 deletions lib/drivers/medtronic600/medtronic600Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 2 additions & 4 deletions test/node/medtronic600/testMedtronic600Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
});

Expand Down

0 comments on commit d20a068

Please sign in to comment.