Skip to content

Commit

Permalink
Merge pull request #1 from nightscout/wip/push-notify
Browse files Browse the repository at this point in the history
add back the x field to treatments so they can be used like normal en…
  • Loading branch information
Paul Andrel committed Jun 19, 2015
2 parents 980c45e + c0588fa commit 096bc9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ function init(env, ctx) {
var tq = {find: {"created_at": {"$gte": new Date(treatment_earliest_data).toISOString()}}};
ctx.treatments.list(tq, function (err, results) {
if (!err && results) {
var treatments = [];
treatments = results.map(function (treatment) {
var treatments = results.map(function (treatment) {
treatment.created_at = new Date(treatment.created_at).getTime();
//TODO: #CleanUpDataModel, some code expects x everywhere
treatment.x = treatment.created_at;
return treatment;
});

Expand Down
9 changes: 9 additions & 0 deletions tests/data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ describe('Data', function ( ) {
delta.sgvs.length.should.equal(1);
});

it('adding one treatment record should return delta with one treatment', function() {
data.treatments = [{sgv: 100, x:100},{sgv: 100, x:99}];
var newData = data.clone();
newData.treatments = [{sgv: 100, x:100},{sgv: 100, x:99},{sgv: 100, x:98}];
var delta = data.calculateDeltaBetweenDatasets(data,newData);
delta.delta.should.equal(true);
delta.treatments.length.should.equal(1);
});

it('changes to treatments, mbgs and cals should be calculated even if sgvs is not changed', function() {
data.sgvs = [{sgv: 100, x:100},{sgv: 100, x:99}];
data.treatments = [{sgv: 100, x:100},{sgv: 100, x:99}];
Expand Down

0 comments on commit 096bc9b

Please sign in to comment.