Skip to content

Commit

Permalink
Don't use dynamic scale unless entries in database (#5195)
Browse files Browse the repository at this point in the history
* don't use dynamic scale unless have entries

* fix report crash when no entries

* set forecastTime correctly when no entries present
  • Loading branch information
jpcunningh authored and sulkaharo committed Nov 12, 2019
1 parent 0c6929f commit 534c443
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/client/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function init (client, d3, $) {
}

function dynamicDomainOrElse (defaultDomain) {
if (client.settings.scaleY === 'linear' || client.settings.scaleY === 'log-dynamic') {
if (client.entries && (client.entries.length > 0) && (client.settings.scaleY === 'linear' || client.settings.scaleY === 'log-dynamic')) {
return dynamicDomain();
} else {
return defaultDomain;
Expand Down Expand Up @@ -714,7 +714,10 @@ function init (client, d3, $) {
}

maxForecastMills = Math.min(focusHoursAheadMills, maxForecastMills);
client.forecastTime = maxForecastMills > 0 ? maxForecastMills - client.sbx.lastSGVMills() : 0;

var lastSGVMills = client.sbx.lastSGVMills();

client.forecastTime = ((maxForecastMills > 0) && lastSGVMills) ? maxForecastMills - lastSGVMills : client.defaultForecastTime;
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ client.load = function load (serverSettings, callback) {

client.now = Date.now();
client.ddata = require('../data/ddata')();
client.forecastTime = times.mins(30).msecs;
client.forecastTime = client.defaultForecastTime = times.mins(30).msecs;
client.entries = [];
client.ticks = require('./ticks');

Expand Down
5 changes: 5 additions & 0 deletions lib/report_plugins/glucosedistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s

var glucose_data = [data[0]];

if (data.length === 0) {
$('#glucosedistribution-days').text(translate('Result is empty'));
return;
}

// data cleaning pass 1 - add interpolated missing points
for (i = 0; i <= data.length - 2; i++) {
var entry = data[i];
Expand Down

0 comments on commit 534c443

Please sign in to comment.