Skip to content

Commit

Permalink
Fix Issue #5486 - Device Status Days Feature (#5651)
Browse files Browse the repository at this point in the history
* Device Status Days Feature

* Edits per review from @sulkaharo
  • Loading branch information
mtfoley authored Jun 12, 2020
1 parent db0e08c commit f3fab56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ For remote overrides, the following extended settings must be configured:
Plugins only have access to their own extended settings, all the extended settings of client plugins will be sent to the browser.

* `DEVICESTATUS_ADVANCED` (`true`) - Defaults to true. Users who only have a single device uploading data to Nightscout can set this to false to reduce the data use of the site.
* `DEVICESTATUS_DAYS` (`1`) - Defaults to 1, can optionally be set to 2. Users can use this to show 48 hours of device status data for in retro mode, rather than the default 24 hours. Setting this value to 2 will roughly double the bandwidth usage of nightscout, so users with a data cap may not want to update this setting.

#### Pushover
In addition to the normal web based alarms, there is also support for [Pushover](https://pushover.net/) based alarms and notifications.
Expand Down
2 changes: 2 additions & 0 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function findExtendedSettings (envs) {

extended.devicestatus = {};
extended.devicestatus.advanced = true;
extended.devicestatus.days = 1;
if(process.env['DEVICESTATUS_DAYS'] && process.env['DEVICESTATUS_DAYS'] == '2') extended.devicestatus.days = 1;

function normalizeEnv (key) {
return key.toUpperCase().replace('CUSTOMCONNSTR_', '');
Expand Down
4 changes: 3 additions & 1 deletion lib/data/dataloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ function loadFood(ddata, ctx, callback) {
}

function loadDeviceStatus(ddata, env, ctx, callback) {
var retroDays = ONE_DAY;
if(env.extendedSettings.devicestatus && env.extendedSettings.devicestatus.days && env.extendedSettings.devicestatus.days == 2) retroDays = TWO_DAYS;
var dateRange = {
$gte: new Date(ddata.lastUpdated - ONE_DAY).toISOString()
$gte: new Date( ddata.lastUpdated - (retroDays) ).toISOString()
};
if (ddata.page && ddata.page.frame) {
dateRange['$lte'] = new Date(ddata.lastUpdated).toISOString();
Expand Down

0 comments on commit f3fab56

Please sign in to comment.