nightscout / cgm-remote-monitor

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

Missing data when full sync from AAPS to new Nightscout instance #8097

Open NonLoSoK opened 11 months ago

NonLoSoK commented 11 months ago

Describe the bug When trying to do a full sync of the data from AAPS to a new nightscout instance, only part of the data gets written in the database. It's been a while since I've troubleshooted this issue, but from what I recall, in the nightscout AAPS tab the entries showed as db update, even if the db was empty. Was not able to find correlation from the data that was actually being written and the one that was not, seemed random to me.

To Reproduce

  1. Create new instance of nightscout
  2. From the Nightscout AAPS tab click on the three dots on the top right and click full sync
  3. Missing data in mongodb

Expected behavior All the data should be uploaded

Your setup information

The fix that worked for me Edit lib/server/websocket.js function at line 214 in:

 ctx.store.collection(collection).update({ '_id': id }
    , { $set: data.data }
    , {upsert: true}  <--
    , function(err, results) {
        ....