mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
changed offset to 10 minues; store/check lastMBG time to prevent sending dupes
This commit is contained in:
+8
-4
@@ -3,7 +3,7 @@
|
||||
var es = require('event-stream');
|
||||
var sgvdata = require('sgvdata');
|
||||
|
||||
var TWENTY_MINS = 20 * 60 * 1000;
|
||||
var TEN_MINS = 10 * 60 * 1000;
|
||||
|
||||
/**********\
|
||||
* Entries
|
||||
@@ -114,10 +114,13 @@ function entries (name, storage, pushover) {
|
||||
});
|
||||
}
|
||||
|
||||
//currently the Android upload will send the last MBG over and over, make sure we get a single notification
|
||||
var lastMBG = 0;
|
||||
|
||||
function sendPushover(doc) {
|
||||
if (doc.type && doc.mbg && doc.type == 'mbg' && doc.date && pushover) {
|
||||
var offset = Math.abs(doc.date - new Date().getTime());
|
||||
if (offset > TWENTY_MINS) {
|
||||
if (doc.type && doc.mbg && doc.type == 'mbg' && doc.date && doc.date != lastMBG && pushover) {
|
||||
var offset = new Date().getTime() - doc.date;
|
||||
if (offset > TEN_MINS) {
|
||||
console.info('No MBG Pushover, offset: ' + offset + ' too big, doc.date: ' + doc.date + ', now: ' + new Date().getTime());
|
||||
} else {
|
||||
var msg = {
|
||||
@@ -134,6 +137,7 @@ function entries (name, storage, pushover) {
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
lastMBG = doc.date;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user