nightscout / cgm-remote-monitor

nightscout web monitor
GNU Affero General Public License v3.0
2.38k stars 71.59k forks source link

WIP: fix WS v1 #8111

Closed MilosKozak closed 1 month ago

bewest commented 10 months ago

Looks ok. For contrast, here's how Sulka updated similar areas, it reads a little differently but I think winds up being functionally equivalent.

https://github.com/nightscout/cgm-remote-monitor/blob/master/lib/server/devicestatus.js#L26-L58

bewest commented 10 months ago

Looks like we might have a check list of sorts:

bewest@equitous:~/src/cgm-remote-monitor$ git grep "insert("
lib/api3/generic/create/operation.js:    await insert(opCtx, doc);
lib/api3/generic/update/operation.js:    await insert(opCtx, doc);
lib/server/activity.js:    api().insert(obj, function (err, doc) {
lib/server/food.js:    api().insert(obj, function (err, doc) {
lib/server/profile.js:    api().insert(obj, function (err, doc) {
lib/server/websocket.js:              ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
lib/server/websocket.js:          ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
lib/server/websocket.js:          ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
testing/populate.js:  cgm_collection.insert(new_cgm_record, function (err) {
bewest@equitous:~/src/cgm-remote-monitor$ git grep "insert("^C
bewest@equitous:~/src/cgm-remote-monitor$ git grep "insertOne("
lib/api3/generic/create/insert.js:  const identifier = await col.storage.insertOne(doc);
lib/api3/storage/mongoCachedCollection/index.js:    const result = await baseStorage.insertOne(doc, { normalize: false });
lib/api3/storage/mongoCollection/index.js:  self.insertOne = (...args) => modify.insertOne(self.col, ...args);
lib/api3/storage/mongoCollection/modify.js:    col.insertOne(doc, function mongoDone(err, result) {
lib/authorization/storage.js:      collection.insertOne(obj, function (err, doc) {
lib/authorization/storage.js:      collection.insertOne(obj, function (err) {
lib/server/devicestatus.js:      api().insertOne(obj, function(err, results) {
bewest commented 10 months ago

Should we roll back https://github.com/nightscout/cgm-remote-monitor/pull/8026 or continue to make changes?

MilosKozak commented 10 months ago

@bewest it's up to you. this patch is working and ready. But we must resolve all other places .... and not only insert but update and remove as well

MilosKozak commented 10 months ago

if rollback makes no conflicts maybe I'd prefer it as a fast solution and create branch with this commit + patch as a new version

MilosKozak commented 10 months ago

calling ctx.bus.emit('data-update' .... on collection level is better anyway

bewest commented 10 months ago

https://github.com/nightscout/cgm-remote-monitor/pull/8115