Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6 from nightscout/express-cache
Browse files Browse the repository at this point in the history
bgdelta also
  • Loading branch information
brianhanifin committed Jul 1, 2014
2 parents 8c4016f + be57b35 commit 5cee972
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/pebble.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ function pebble (req, res) {
console.log('queried', new Date(earliest_data).toISOString( ),
new Date(now).toISOString( ), 'got raw results', results.length);
results.forEach(function(element, index, array) {
var last = cgmData[cgmData.length - 1];
var next = null;
if (index + 1 < results.length) {
next = results[index + 1];
}
if (element) {
console.log(element, index);
var obj = {};
obj.sgv = element.sgv;
obj.bgdelta = (last ? (last.sgv - element.sgv) : 0);
obj.bgdelta = (next ? (element.sgv - next.sgv ) : 0);
if ('direction' in element) {
obj.trend = directionToTrend(element.direction);
obj.direction = element.direction;
Expand Down

0 comments on commit 5cee972

Please sign in to comment.