Skip to content

Commit

Permalink
Merge pull request #2 from nightscout/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
emielmiddel authored Feb 13, 2018
2 parents 6ada41d + 75e195a commit 746b318
Show file tree
Hide file tree
Showing 48 changed files with 1,836 additions and 790 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/

bundle/bundle.out.js

.vscode/
.idea/
*.iml
my.env
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.1.4
8.9.1
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
sudo: required
dist: trusty
node_js:
- "8.5.0"
- "8.9.1"
matrix:
fast_finish: true
services:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.5.0
FROM node:8.9.1

MAINTAINER Nightscout Contributors

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ all: test

coverage:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} -- --timeout 30000 -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} -- --timeout 15000 -R tap ${TESTS}

report:
test -f ${ANALYZED} && \
Expand All @@ -45,7 +45,7 @@ test:

travis:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 50000 -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}

docker_release:
# Get the version from the package.json file
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ Community maintained fork of the

Requirements:

- [Node.js](http://nodejs.org/)
- [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:

```bash
$ npm install
```

If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.5.0* or the site deployment will fail. Other hosting environments do not require this setting.
If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.9.0* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting.

# Usage

The data being uploaded from the server to the client is from a
MongoDB server such as [mongolab][mongodb].

[mongodb]: https://mongolab.com
[autoconfigure]: http://nightscout.github.io/pages/configure/
[mongostring]: http://nightscout.github.io/pages/mongostring/
[autoconfigure]: https://nightscout.github.io/pages/configure/
[mongostring]: https://nightscout.github.io/pages/mongostring/
[update-fork]: http://nightscout.github.io/pages/update-fork/

## Updating my version?
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function create(env, ctx) {
json_match: /json/,
uglifyJS: myUglifyJS,
cssmin: myCssmin,
cache: __dirname + '/cache',
cache: __dirname + '/tmp',
onerror: undefined,
}));

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nightscout",
"version": "0.10.0-dev-20170716",
"version": "0.10.2-release-20171201",
"dependencies": {
"colorbrewer": "~1.0.0",
"jQuery-Storage-API": "~1.7.2",
Expand Down
11 changes: 11 additions & 0 deletions docs/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Please include the following information with your bug report:

Is this a new bug with the latest release, have you seen this earlier?

Which device / browser version was used to reproduce the bug?

Does this happen every time you launch Nightscout, or sometimes?

Steps how to reproduce (if you can’t reproduce the issue, please don’t report the issue / if we can't reproduce the bug, we can't fix)

Please include 1 or more screenshots of the issue appearing, ideally with an annotation on what's wrong
2 changes: 1 addition & 1 deletion lib/api/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function configure (app, wares, ctx) {
var ifModifiedSince = req.get('If-Modified-Since');
if (!ifModifiedSince) { return next(); }

if (lastEntryDate <= new Date(ifModifiedSince)) {
if (lastEntryDate.getTime() <= new Date(ifModifiedSince).getTime()) {
res.status(304).send({status:304, message: 'Not modified', type:'internal'});
return;
}
Expand Down
17 changes: 14 additions & 3 deletions lib/api/treatments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var _ = require('lodash');
var consts = require('../../constants');
var moment = require('moment');

function configure(app, wares, ctx) {
var express = require('express')
Expand Down Expand Up @@ -39,16 +40,26 @@ function configure(app, wares, ctx) {
t.carbs = Number(t.carbs);
t.insulin = Number(t.insulin);

var d2 = new Date(t.timestamp);
var d2 = null;

if (d1 == null || d2 > d1) {
if (t.hasOwnProperty('created_at')) {
d2 = new Date(t.created_at);
} else {
if (t.hasOwnProperty('timestamp')) {
d2 = new Date(t.timestamp);
}
}

if (d2 == null) { return; }

if (d1 == null || d2.getTime() > d1.getTime()) {
d1 = d2;
}
});

if (!_.isNil(d1)) res.setHeader('Last-Modified', d1.toUTCString());

if (ifModifiedSince && d1 <= new Date(ifModifiedSince)) {
if (ifModifiedSince && d1.getTime() <= moment(ifModifiedSince).valueOf()) {
res.status(304).send({
status: 304
, message: 'Not modified'
Expand Down
54 changes: 27 additions & 27 deletions lib/client/boluscalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,41 +621,41 @@ function init(client, $) {
boluscalc.loadFoodDatabase = function loadFoodDatabase(event, callback) {
categories = [];
foodlist = [];
$.ajax('/api/v1/food/regular.json', {
headers: client.headers()
, success: function (records) {
records.forEach(function (r) {
foodlist.push(r);
if (r.category && !categories[r.category]) {
categories[r.category] = {};
}
if (r.category && r.subcategory) {
categories[r.category][r.subcategory] = true;
}
});
databaseloaded = true;
console.log('Food database loaded');
fillForm();
var records = client.sbx.data.food || [];
records.forEach(function (r) {
if (r.type == 'food') {
foodlist.push(r);
if (r.category && !categories[r.category]) {
categories[r.category] = {};
}
if (r.category && r.subcategory) {
categories[r.category][r.subcategory] = true;
}
}
}).done(function() { if (callback) { callback(); } });
});
databaseloaded = true;
console.log('Food database loaded');
fillForm();
maybePrevent(event);
if (callback) { callback(); }
};

boluscalc.loadFoodQuickpicks = function loadFoodQuickpicks( ) {
// Load quickpicks
$.ajax('/api/v1/food/quickpicks.json', {
headers: client.headers()
, success: function (records) {
quickpicks = records;
$('#bc_quickpick').empty().append('<option value="-1">' + translate('(none)') + '</option>');
for (var i=0; i<records.length; i++) {
var r = records[i];
$('#bc_quickpick').append('<option value="' + i +'">' + r.name + ' (' + r.carbs + ' g)</option>');
};
$('#bc_quickpick').val(-1);
$('#bc_quickpick').change(quickpickChange);
quickpicks = [];
var records = client.sbx.data.food || [];
records.forEach(function (r) {
if (r.type == 'quickpick') {
quickpicks.push(r);
}
});
$('#bc_quickpick').empty().append('<option value="-1">' + translate('(none)') + '</option>');
for (var i=0; i<records.length; i++) {
var r = records[i];
$('#bc_quickpick').append('<option value="' + i +'">' + r.name + ' (' + r.carbs + ' g)</option>');
};
$('#bc_quickpick').val(-1);
$('#bc_quickpick').change(quickpickChange);
};

function fillForm(event) {
Expand Down
12 changes: 9 additions & 3 deletions lib/client/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ function init (client, d3, $) {
var contextYDomain = [utils.scaleMgdl(36), utils.scaleMgdl(420)];

function dynamicDomain() {
var mult = 1.3
// allow y-axis to extend all the way to the top of the basal area, but leave room to display highest value
var mult = 1.15
, targetTop = client.settings.thresholds.bgTargetTop
, mgdlMax = d3.max(client.entries, function (d) { return d.mgdl; });
// filter to only use actual SGV's (not rawbg's) to set the view window.
// can switch to Logarithmic (non-dynamic) to see anything that doesn't fit in the dynamicDomain
, mgdlMax = d3.max(client.entries, function (d) { if ( d.type === 'sgv') { return d.mgdl; } });
// use the 99th percentile instead of max to avoid rescaling for 1 flukey data point
// need to sort client.entries by mgdl first
//, mgdlMax = d3.quantile(client.entries, 0.99, function (d) { return d.mgdl; });

return [
utils.scaleMgdl(30)
Expand Down Expand Up @@ -505,7 +511,7 @@ function init (client, d3, $) {

var updateBrush = d3.select('.brush').transition();
updateBrush
.call(chart.brush.extent([new Date(dataRange[1].getTime() - client.foucusRangeMS), dataRange[1]]));
.call(chart.brush.extent([new Date(dataRange[1].getTime() - client.focusRangeMS), dataRange[1]]));
client.brushed(true);

renderer.addContextCircles();
Expand Down
14 changes: 7 additions & 7 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ client.load = function load(serverSettings, callback) {

client.hashauth.initAuthentication(client.afterAuth);

client.foucusRangeMS = times.hours(client.settings.focusHours).msecs;
client.focusRangeMS = times.hours(client.settings.focusHours).msecs;
$('.focus-range li[data-hours=' + client.settings.focusHours + ']').addClass('selected');
client.brushed = brushed;
client.formatTime = formatTime;
Expand Down Expand Up @@ -365,7 +365,7 @@ client.load = function load(serverSettings, callback) {
d3.select('.brush')
.transition()
.duration(UPDATE_TRANS_MS)
.call(chart.brush.extent([new Date(dataRange[1].getTime() - client.foucusRangeMS), dataRange[1]]));
.call(chart.brush.extent([new Date(dataRange[1].getTime() - client.focusRangeMS), dataRange[1]]));

if (!skipBrushing) {
brushed();
Expand All @@ -385,14 +385,14 @@ client.load = function load(serverSettings, callback) {
var brushExtent = chart.brush.extent();

// ensure that brush extent is fixed at 3.5 hours
if (brushExtent[1].getTime() - brushExtent[0].getTime() !== client.foucusRangeMS) {
if (brushExtent[1].getTime() - brushExtent[0].getTime() !== client.focusRangeMS) {
// ensure that brush updating is with the time range
if (brushExtent[0].getTime() + client.foucusRangeMS > client.dataExtent()[1].getTime()) {
brushExtent[0] = new Date(brushExtent[1].getTime() - client.foucusRangeMS);
if (brushExtent[0].getTime() + client.focusRangeMS > client.dataExtent()[1].getTime()) {
brushExtent[0] = new Date(brushExtent[1].getTime() - client.focusRangeMS);
d3.select('.brush')
.call(chart.brush.extent([brushExtent[0], brushExtent[1]]));
} else {
brushExtent[1] = new Date(brushExtent[0].getTime() + client.foucusRangeMS);
brushExtent[1] = new Date(brushExtent[0].getTime() + client.focusRangeMS);
d3.select('.brush')
.call(chart.brush.extent([brushExtent[0], brushExtent[1]]));
}
Expand Down Expand Up @@ -868,7 +868,7 @@ client.load = function load(serverSettings, callback) {
$('.focus-range li').removeClass('selected');
li.addClass('selected');
var hours = Number(li.data('hours'));
client.foucusRangeMS = times.hours(hours).msecs;
client.focusRangeMS = times.hours(hours).msecs;
Storages.localStorage.set('focusHours', hours);
refreshChart();
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/receiveddata.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function receiveDData (received, ddata, settings) {
ddata.mbgs = mergeDataUpdate(received.delta, ddata.mbgs, received.mbgs);
ddata.treatments = mergeTreatmentUpdate(received.delta, ddata.treatments, received.treatments);

ddata.processTreatments(true);
ddata.processTreatments(false);

// Do some reporting on the console
// console.log('Total SGV data size', ddata.sgvs.length);
Expand Down
Loading

0 comments on commit 746b318

Please sign in to comment.