Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #5486 - Device Status Days Feature #5651

Merged
merged 2 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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