Skip to content

Commit

Permalink
Merge pull request #2 from nightscout/autotune
Browse files Browse the repository at this point in the history
Autotune update from nightscout
  • Loading branch information
lixgbg authored Mar 10, 2018
2 parents 63a9ad7 + c9fdeb5 commit 584fcdb
Show file tree
Hide file tree
Showing 55 changed files with 1,260 additions and 2,787 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.9.1
8.9.x
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ language: node_js
sudo: required
dist: trusty
node_js:
- "8.9.1"
- "8.9.3"
before_install: if [[ `npm --version` != "5.6" ]]; then npm install -g npm@latest; npm --version; fi
matrix:
fast_finish: true
services:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Community maintained fork of the

Requirements:

- [Node.js](http://nodejs.org/) 8.9.1 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
- [Node.js](http://nodejs.org/) 8.9.0 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)

Clone this repo then install dependencies into the root of the project:

Expand Down Expand Up @@ -228,7 +228,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `NIGHT_MODE` (`off`) - possible values `on` or `off`
* `SHOW_RAWBG` (`never`) - possible values `always`, `never` or `noise`
* `CUSTOM_TITLE` (`Nightscout`) - Usually name of T1
* `THEME` (`default`) - possible values `default` or `colors`
* `THEME` (`default`) - possible values `default`, `colors`, or `colorblindfriendly`
* `ALARM_TIMEAGO_WARN` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_WARN_MINS` (`15`) - minutes since the last reading to trigger a warning
* `ALARM_TIMEAGO_URGENT` (`on`) - possible values `on` or `off`
Expand Down
52 changes: 21 additions & 31 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"required": true
},
"API_SECRET": {
"description": "REQUIRED: A secret passphrase that must be at least 12 characters long, required to enable POST and PUT; also required for the Care Portal",
"description": "REQUIRED: A secret passphrase that must be at least 12 characters long, required to enable POST and PUT; also required for the Care Portal.",
"value": "",
"required": true
},
Expand All @@ -18,12 +18,12 @@
"required": false
},
"ENABLE": {
"description": "Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info",
"description": "Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info.",
"value": "",
"required": false
},
"DISABLE": {
"description": "Used to disable default features, expects a space delimited list, such as: direction upbat, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info",
"description": "Used to disable default features, expects a space delimited list, such as: direction upbat, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info.",
"value": "",
"required": false
},
Expand All @@ -33,22 +33,22 @@
"required": false
},
"BG_HIGH": {
"description": "Urgent high BG alarm. Default null value implies 260. Must be set in mg/dL. Only used with simple alarms.",
"description": "Urgent high BG alarm. Default null value implies 260. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_TARGET_TOP": {
"description": "Non-urgent high BG alarm, the top of your target range. Default null value implies 180. Must be set in mg/dL. Only used with simple alarms.",
"description": "Non-urgent high BG alarm, the top of your target range. Default null value implies 180. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_TARGET_BOTTOM": {
"description": "Non urgent low BG alarm, the bottom of your target range. Default null value implies 80. Must be set in mg/dL. Only used with simple alarms.",
"description": "Non urgent low BG alarm, the bottom of your target range. Default null value implies 80. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_LOW": {
"description": "Urgent Low BG alarm. Default null value implies 55. Must be set in mg/dL. Only used with simple alarms.",
"description": "Urgent Low BG alarm. Default null value implies 55. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
Expand All @@ -72,83 +72,73 @@
"value": "",
"required": false
},
"THEME": {
"description": "Possible values default, colors or colorblindfriendly",
"value": "",
"required": false
},
"SHOW_RAWBG": {
"description": "Possible values always, never or noise",
"value": "",
"required": false
},
"BRIDGE_USER_NAME": {
"description": "Share bridge - Your user name for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge",
"description": "Share bridge - Your user name for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge.",
"value": "",
"required": false
},
"BRIDGE_PASSWORD": {
"description": "Share bridge - Your password for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge",
"description": "Share bridge - Your password for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge.",
"value": "",
"required": false
},
"TIME_FORMAT": {
"description": "Browser default time mode valid settings are 12 or 24",
"description": "Browser default time mode. Valid settings are 12 or 24",
"value": "12",
"required": false
},
"NIGHT_MODE": {
"description": "Browser defaults to night mode valid settings are on or off",
"description": "Browser defaults to night mode. Valid settings are on or off",
"value": "off",
"required": false
},
"SHOW_RAWBG": {
"description": "Browser default raw display mode vaild settings are always never or noise",
"description": "Browser default raw display mode. Valid settings are always, never, or noise",
"value": "never",
"required": false
},
"THEME": {
"description": "Browser default theme setting vaild settings are default or colors",
"description": "Browser default theme setting. Valid settings are default, colors, or colorblindfriendly",
"value": "default",
"required": false
},
"ALARM_URGENT_HIGH": {
"description": "Browser default urgent high alarm enabled vaild settings are on or off",
"description": "Browser default urgent high alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_HIGH": {
"description": "Browser default high alarm enabled vaild settings are on or off",
"description": "Browser default high alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_LOW": {
"description": "Browser default low alarm enabled vaild settings are on or off",
"description": "Browser default low alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_URGENT_LOW": {
"description": "Browser default urgent low alarm enabled vaild settings are on or off",
"description": "Browser default urgent low alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_WARN": {
"description": "Browser default warn after time of last data exceeds ALARM_TIMEAGO_WARN_MINS alarm enabled vaild settings are on or off",
"description": "Browser default warn after time of last data exceeds ALARM_TIMEAGO_WARN_MINS alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_WARN_MINS": {
"description": "Browser default minutes since the last reading to trigger a warning",
"description": "Browser default minutes since the last reading to trigger a warning.",
"value": "15",
"required": false
},
"ALARM_TIMEAGO_URGENT": {
"description": "Browser default urgent warning after time of last data exceeds ALARM_TIMEAGO_URGENT_MINS alarm enabled vaild settings are on or off",
"description": "Browser default urgent warning after time of last data exceeds ALARM_TIMEAGO_URGENT_MINS alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_URGENT_MINS": {
"description": "Browser default minutes since last reading to trigger an urgent alarm",
"description": "Browser default minutes since last reading to trigger an urgent alarm.",
"value": "30",
"required": false
},
Expand Down
17 changes: 0 additions & 17 deletions bower.json

This file was deleted.

1 change: 1 addition & 0 deletions bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function bundle(env) {
watch: __dirname + '/../lib/',
mount: '/public/js/bundle.js',
verbose: true,
minify: env.debug.minify,
bundle_opts: { debug: true }, // enable inline sourcemap on js files
write_file: __dirname + '/bundle.out.js'
});
Expand Down
19 changes: 0 additions & 19 deletions lib/api/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,6 @@ function configure (app, wares, ctx) {
return next();
}

// check for last modified from query results

function ifModifiedSince (req, res, next) {

var lastEntryDate = new Date(_.last(res.entries).dateString);
res.setHeader('Last-Modified', lastEntryDate.toUTCString());

var ifModifiedSince = req.get('If-Modified-Since');

if (!ifModifiedSince) { return next(); }

if (lastEntryDate <= new Date(ifModifiedSince)) {
res.status(304).send({status:304, message: 'Not modified', type:'internal'});
return;
}

return next();
}

/**
* @method format_entries
* A final middleware to send payloads assembled by previous middlewares
Expand Down
2 changes: 1 addition & 1 deletion lib/authorization/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var crypto = require('crypto');
var shiroTrie = require('shiro-trie');
var ObjectID = require('mongodb').ObjectID;

var find_options = require('../query');
var find_options = require('../server/query');

function init (env, ctx) {
var storage = { };
Expand Down
1 change: 1 addition & 0 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ client.load = function load(serverSettings, callback) {
chart.update(true);
} else if (!inRetroMode()) {
chart.update(false);
client.plugins.updateVisualisations(client.nowSBX);
}

}
Expand Down
7 changes: 0 additions & 7 deletions lib/client/receiveddata.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,15 @@ function mergeDataUpdate(isDelta, cachedDataArray, receivedDataArray, maxAge) {
}

// purge old data from cache before updating
var purgeCount = 0;
var mAge = (isNaN(maxAge) || maxAge == null) ? TWO_DAYS : maxAge;
var twoDaysAgo = new Date().getTime() - mAge;

for (var i = 0; i < cachedDataArray.length; i++) {
var element = cachedDataArray[i];
if (element !== null && element !== undefined && element.mills <= twoDaysAgo) {
cachedDataArray.splice(i,0);
purgeCount += 1;
}
}

//if (purgeCount > 0) {
// console.log('Purged ' + purgeCount + ' elements from cache due to age');
//}


// If this is delta, calculate the difference, merge and sort
var diff = nsArrayDiff(cachedDataArray, receivedDataArray);
Expand Down
18 changes: 8 additions & 10 deletions lib/client/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ function init (client, d3) {

function calcTreatmentRadius(treatment, opts, carbratio) {
var CR = treatment.CR || carbratio || 20;
var carbs = treatment.carbs || CR;
var insulin = treatment.insulin || 1;
var carbsOrInsulin = CR;
if ( treatment.carbs ) {
carbsOrInsulin = treatment.carbs;
Expand Down Expand Up @@ -445,10 +443,10 @@ function init (client, d3) {

if ( treatment.insulin > 0) {
var dosage_units = '' + Math.round(treatment.insulin * 100)/100;

var unit_of_measurement = ' U'; // One international unit of insulin (1 IU) is shown as '1 U'
var enteredBy = '' + treatment.enteredBy;

if ( treatment.insulin < 1 && !treatment.carbs && enteredBy.indexOf('openaps') > -1) { // don't show the unit of measurement for insulin boluses < 1 without carbs (e.g. oref0 SMB's). Otherwise lot's of small insulin only dosages are often unreadable
unit_of_measurement = '';
// remove leading zeros to avoid overlap with adjacent boluses
Expand Down Expand Up @@ -860,9 +858,9 @@ function init (client, d3) {
.attr('class', 'path')
.attr('id', 'label')
.style('fill', 'white');

// reduce the treatment label font size to make it readable with SMB
var fontBaseSize = (opts.treatments >= 50) ? 40 : 50 - Math.floor((60-opts.treatments)/50 * 10);
var fontBaseSize = (opts.treatments >= 30) ? 40 : 50 - Math.floor((25-opts.treatments)/30 * 10);

label.append('text')
.style('font-size', fontBaseSize / opts.scale)
Expand All @@ -881,13 +879,13 @@ function init (client, d3) {
}

renderer.drawTreatments = function drawTreatments(client) {

var treatmentCount = 0;

_.forEach(client.ddata.treatments, function eachTreatment (d) {
if (Number(d.insulin) > 0 || Number(d.carbs) > 0) { treatmentCount += 1; };
if (Number(d.insulin) > 0 || Number(d.carbs) > 0) { treatmentCount += 1; };
});

// add treatment bubbles
_.forEach(client.ddata.treatments, function eachTreatment (d) {
renderer.drawTreatment(d, {
Expand Down
Loading

0 comments on commit 584fcdb

Please sign in to comment.