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

Update mongo libs from 3.6 to 5 #8314

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 0 deletions lib/client/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ function init (client, d3) {
chart().basals.attr('display', 'none');

operation = 'Move';
var x = Math.min(Math.max(0, d3.event.x), chart().charts.attr('width'));
newTime = new Date(chart().xScale.invert(x));
})
.on('drag', function() {
//console.log(d3.event);
Expand Down
25 changes: 16 additions & 9 deletions lib/server/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function init (env, ctx, server) {
// field_2: another_value
// }
// }
// TODO: tests, data models
socket.on('dbAdd', function dbAdd (data, callback) {
console.log(LOG_WS + 'dbAdd client ID: ', socket.client.id, ' data: ', data);
var collection = supportedCollections[data.collection];
Expand Down Expand Up @@ -405,20 +406,22 @@ function init (env, ctx, server) {
}
// if not found create new record
console.log(LOG_DEDUP + 'Adding new record');
ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
ctx.store.collection(collection).insertOne(data.data, function insertResult (err, ops) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AAPS folks: do multiple documents come through this interface as an array? Can you provide any examples?

if (err != null && err.message) {
console.log('treatments data insertion error: ', err.message);
return;
}

var doc = data.data;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a roadmap or anything around browser support? How much longer will the codebase use var instead of let/const?

Looks like any android/ios device since 2011 should support let/const - there are no vendor-currently-supported os/browser combinations that don't support them.

Maybe the approach could be "use nightscout 15 for old browsers" and do any work on the f/e to support newer testing/frameworks in a nightscout v16 that will only support newer browsers? I think you'll rapidly paint yourself into a corner if "we're not waiting" becomes "we support your ancient devices forever"

doc._id = ops.insertedId;
ctx.bus.emit('data-update', {
type: data.collection
, op: 'update'
, changes: ctx.ddata.processRawDataForRuntime(doc.ops)
, changes: ctx.ddata.processRawDataForRuntime([doc])
});

if (callback) {
callback(doc.ops);
callback([doc]);
}
ctx.bus.emit('data-received');
});
Expand Down Expand Up @@ -453,38 +456,42 @@ function init (env, ctx, server) {

});

ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
ctx.store.collection(collection).insertOne(data.data, function insertResult (err, ops) {
if (err != null && err.message) {
console.log('devicestatus insertion error: ', err.message);
return;
}

var doc = data.data;
doc._id = ops.insertedId;
ctx.bus.emit('data-update', {
type: 'devicestatus'
, op: 'update'
, changes: ctx.ddata.processRawDataForRuntime(doc.ops)
, changes: ctx.ddata.processRawDataForRuntime([doc])
});

if (callback) {
callback(doc.ops);
callback([doc]);
}
ctx.bus.emit('data-received');
});
} else {
ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
ctx.store.collection(collection).insertOne(data.data, function insertResult (err, ops) {
if (err != null && err.message) {
console.log(data.collection + ' insertion error: ', err.message);
return;
}

var doc = data.data;
doc._id = ops.insertedId;
ctx.bus.emit('data-update', {
type: data.collection
, op: 'update'
, changes: ctx.ddata.processRawDataForRuntime(doc.ops)
, changes: ctx.ddata.processRawDataForRuntime([doc])
});

if (callback) {
callback(doc.ops);
callback([doc]);
}
ctx.bus.emit('data-received');
});
Expand Down