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

Nightscout release 14.0.6 Liquorice #6148

Merged
merged 3 commits into from
Sep 28, 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
2 changes: 1 addition & 1 deletion lib/server/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function cache (env, ctx) {
}

data.isEmpty = (datatype) => {
return data[datatype].length == 0;
return data[datatype].length < 20;
}

data.getData = (datatype) => {
Expand Down
70 changes: 45 additions & 25 deletions lib/server/devicestatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,51 @@ var find_options = require('./query');

function storage (collection, ctx) {

function create (obj, fn) {

// Normalize all dates to UTC
const d = moment(obj.created_at).isValid() ? moment.parseZone(obj.created_at) : moment();
obj.created_at = d.toISOString();
obj.utcOffset = d.utcOffset();

api().insertOne(obj, function(err, results) {
if (err !== null && err.message) {
console.log('Error inserting the device status object', err.message);
fn(err.message, null);
return;
}
function create (statuses, fn) {

if (!err) {
if (!Array.isArray(statuses)) { statuses = [statuses]; }

if (!obj._id) obj._id = results.insertedIds[0]._id;
const r = [];
let errorOccurred = false;

ctx.bus.emit('data-update', {
type: 'devicestatus'
, op: 'update'
, changes: ctx.ddata.processRawDataForRuntime([obj])
});
}
for (let i = 0; i < statuses.length; i++) {

fn(null, results.ops);
ctx.bus.emit('data-received');
});
const obj = statuses[i];

if (errorOccurred) return;

// Normalize all dates to UTC
const d = moment(obj.created_at).isValid() ? moment.parseZone(obj.created_at) : moment();
obj.created_at = d.toISOString();
obj.utcOffset = d.utcOffset();

api().insertOne(obj, function(err, results) {
if (err !== null && err.message) {
console.log('Error inserting the device status object', err.message);
errorOccurred = true;
fn(err.message, null);
return;
}

if (!err) {

if (!obj._id) obj._id = results.insertedIds[0]._id;
r.push(obj);

ctx.bus.emit('data-update', {
type: 'devicestatus'
, op: 'update'
, changes: ctx.ddata.processRawDataForRuntime([obj])
});

// Last object! Return results
if (i == statuses.length - 1) {
fn(null, r);
ctx.bus.emit('data-received');
}
}
});
};
}

function last (fn) {
Expand Down Expand Up @@ -109,7 +126,10 @@ function storage (collection, ctx) {
api.aggregate = require('./aggregate')({}, api);
api.indexedFields = [
'created_at'





, 'NSCLIENT_ID'
];
return api;
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nightscout",
"version": "14.0.5",
"version": "14.0.6",
"description": "Nightscout acts as a web-based CGM (Continuous Glucose Montinor) to allow multiple caregivers to remotely view a patients glucose data in realtime.",
"license": "AGPL-3.0",
"author": "Nightscout Team",
Expand Down
2 changes: 1 addition & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"info": {
"title": "Nightscout API",
"description": "Own your DData with the Nightscout API",
"version": "14.0.5",
"version": "14.0.6",
"license": {
"name": "AGPL 3",
"url": "https://www.gnu.org/licenses/agpl.txt"
Expand Down
2 changes: 1 addition & 1 deletion swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ servers:
info:
title: Nightscout API
description: Own your DData with the Nightscout API
version: 14.0.5
version: 14.0.6
license:
name: AGPL 3
url: 'https://www.gnu.org/licenses/agpl.txt'
Expand Down