Skip to content

Commit

Permalink
check last_known against null
Browse files Browse the repository at this point in the history
  • Loading branch information
bewest committed Oct 12, 2023
1 parent 4381a9e commit 20ee2b1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/sources/glooko/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function glookoSource (opts, axios) {
},
dataFromSesssion (session, last_known) {
var two_days_ago = new Date( ).getTime( ) - (2 * 24 * 60 * 60 * 1000);
var last_mills = Math.max(two_days_ago, last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
var last_mills = Math.max(two_days_ago, (last_known && last_known.entries) ? last_known.entries.getTime( ) : two_days_ago);
var last_glucose_at = new Date(last_mills);
var maxCount = Math.ceil(((new Date( )).getTime( ) - last_mills) / (1000 * 60 * 5));
var minutes = 5 * maxCount;
Expand Down
2 changes: 1 addition & 1 deletion lib/sources/librelinkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function linkUpSource (opts, axios) {
},
dataFromSesssion (session, last_known) {
var two_days_ago = new Date( ).getTime( ) - (2 * 24 * 60 * 60 * 1000);
var last_mills = Math.max(two_days_ago, last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
var last_mills = Math.max(two_days_ago, (last_known && last_known.entries) ? last_known.entries.getTime( ) : two_days_ago);
var last_glucose_at = new Date(last_mills);
var maxCount = Math.ceil(((new Date( )).getTime( ) - last_mills) / (1000 * 60 * 5));
var minutes = 5 * maxCount;
Expand Down
2 changes: 1 addition & 1 deletion lib/sources/nightscout.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function nightscoutSource (opts, axios) {
dataFromSesssion(session, last_known) {
var two_days_ago = new Date( ).getTime( ) - (2 * 24 * 60 * 60 * 1000);
// var last_mills = Math.max(two_days_ago, last_known.sgvs ? last_known.sgvs.mills : two_days_ago);
var last_mills = Math.max(two_days_ago, last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
var last_mills = Math.max(two_days_ago, (last_known && last_known.entries) ? last_known.entries.getTime( ) : two_days_ago);
var last_glucose_at = new Date(last_mills);
var count = Math.ceil(((new Date( )).getTime( ) - last_mills) / (1000 * 60 * 5));
var query = { find: { dateString: { $gt: last_glucose_at.toISOString( ) } }, count };
Expand Down

0 comments on commit 20ee2b1

Please sign in to comment.