forked from nightscout/minimed-connect-to-nightscout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nightscout#1 from mddub/v1.0.0
Represent pump status as 'device status' entry
- Loading branch information
Showing
10 changed files
with
219 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* jshint node: true */ | ||
"use strict"; | ||
|
||
// Returns a stateful filter which remembers the time of the last-seen entry to | ||
// prevent uploading duplicates. | ||
function makeRecencyFilter(timeFn) { | ||
var lastTime = 0; | ||
|
||
return function(items) { | ||
var out = []; | ||
items.forEach(function(item) { | ||
if (timeFn(item) > lastTime) { | ||
out.push(item); | ||
} | ||
}); | ||
out.forEach(function(item) { | ||
lastTime = Math.max(lastTime, timeFn(item)); | ||
}); | ||
|
||
return out; | ||
}; | ||
} | ||
|
||
module.exports.makeRecencyFilter = makeRecencyFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "minimed-connect-to-nightscout", | ||
"version": "0.2.4", | ||
"version": "1.0.0", | ||
"description": "Send Medtronic pump and CGM data to Nightscout.", | ||
"author": "Mark Wilson <[email protected]>", | ||
"repository": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* jshint node: true */ | ||
/* globals describe, it */ | ||
"use strict"; | ||
|
||
var _ = require('lodash'), | ||
expect = require('expect.js'); | ||
|
||
var makeRecencyFilter = require('../filter.js').makeRecencyFilter; | ||
|
||
describe('makeRecencyFilter()', function() { | ||
it('should return a stateful filter which discards items older than the most recent one seen', function() { | ||
function sgv(date) { | ||
return {type: 'sgv', someDateKey: date}; | ||
} | ||
|
||
var filter = makeRecencyFilter(function(item) { | ||
return item['someDateKey']; | ||
}); | ||
|
||
expect(filter([2, 3, 4].map(sgv))).to.have.length(3); | ||
|
||
expect(filter([2, 3, 4].map(sgv))).to.have.length(0); | ||
|
||
var filtered = filter([2, 3, 4, 8, 6, 7, 5].map(sgv)); | ||
expect(filtered).to.have.length(4); | ||
[5, 6, 7, 8].forEach(function(val) { | ||
expect(_.pluck(filtered, 'someDateKey')).to.contain(val); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.