{"action":"created","issue":{"url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/4080","repository_url":"https://api.github.com/repos/nightscout/cgm-remote-monitor","labels_url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/4080/labels{/name}","comments_url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/4080/comments","events_url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/4080/events","html_url":"https://github.com/nightscout/cgm-remote-monitor/issues/4080","id":382590653,"node_id":"MDU6SXNzdWUzODI1OTA2NTM=","number":4080,"title":"API bug: DELETE devicestatus and treatsments","user":{"login":"VladislavLasmann","id":19853724,"node_id":"MDQ6VXNlcjE5ODUzNzI0","avatar_url":"https://avatars3.githubusercontent.com/u/19853724?v=4","gravatar_id":"","url":"https://api.github.com/users/VladislavLasmann","html_url":"https://github.com/VladislavLasmann","followers_url":"https://api.github.com/users/VladislavLasmann/followers","following_url":"https://api.github.com/users/VladislavLasmann/following{/other_user}","gists_url":"https://api.github.com/users/VladislavLasmann/gists{/gist_id}","starred_url":"https://api.github.com/users/VladislavLasmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladislavLasmann/subscriptions","organizations_url":"https://api.github.com/users/VladislavLasmann/orgs","repos_url":"https://api.github.com/users/VladislavLasmann/repos","events_url":"https://api.github.com/users/VladislavLasmann/events{/privacy}","received_events_url":"https://api.github.com/users/VladislavLasmann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-20T10:14:33Z","updated_at":"2018-11-21T04:12:00Z","closed_at":null,"author_association":"NONE","body":"Using the Nightscout-API to delete the types **devicestatus** and **treatsments** we noticed that the function remove(_id, fn) doesn't work properly. The delete seems to have no effect.\r\n\r\n------------------------------------------\r\n**Treatments:** \r\n _[https://github.com/nightscout/cgm-remote-monitor/blob/master/lib/server/treatments.js](url)\r\nLine: 100_\r\nThe original code looks like this:\r\n`function remove (_id, fn) {\r\n    api( ).remove({ '_id': new ObjectID(_id) }, fn);\r\n    ctx.bus.emit('data-received');\r\n}`\r\n\r\nOur solution:\r\n`function remove (_id, fn) {\r\n    api( ).remove({ '_id': _id }, fn);\r\n    ctx.bus.emit('data-received');\r\n}`\r\n\r\n**Devicestatus:**\r\n _[https://github.com/nightscout/cgm-remote-monitor/blob/master/lib/server/devicestatus.js](url)\r\nLine: 62_\r\nThe original code looks like this:\r\n`function remove (_id, fn) {\r\n    var filter;\r\n    if (_id === '*') {\r\n      filter = {};\r\n    } else {\r\n      filter = { '_id': new ObjectID(_id) };\r\n    }\r\n    return api( ).remove(filter, fn);\r\n  }`\r\n\r\nOur solution:\r\n`function remove (_id, fn) {\r\n    return api( ).remove('_id': _id , fn);\r\n  }`\r\n\r\n------------------------------------------\r\nUsing this fix, the delete function works."},"comment":{"url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/comments/440523435","html_url":"https://github.com/nightscout/cgm-remote-monitor/issues/4080#issuecomment-440523435","issue_url":"https://api.github.com/repos/nightscout/cgm-remote-monitor/issues/4080","id":440523435,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDUyMzQzNQ==","user":{"login":"jpcunningh","id":34543464,"node_id":"MDQ6VXNlcjM0NTQzNDY0","avatar_url":"https://avatars3.githubusercontent.com/u/34543464?v=4","gravatar_id":"","url":"https://api.github.com/users/jpcunningh","html_url":"https://github.com/jpcunningh","followers_url":"https://api.github.com/users/jpcunningh/followers","following_url":"https://api.github.com/users/jpcunningh/following{/other_user}","gists_url":"https://api.github.com/users/jpcunningh/gists{/gist_id}","starred_url":"https://api.github.com/users/jpcunningh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpcunningh/subscriptions","organizations_url":"https://api.github.com/users/jpcunningh/orgs","repos_url":"https://api.github.com/users/jpcunningh/repos","events_url":"https://api.github.com/users/jpcunningh/events{/privacy}","received_events_url":"https://api.github.com/users/jpcunningh/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T04:12:00Z","updated_at":"2018-11-21T04:12:00Z","author_association":"CONTRIBUTOR","body":"#4088 should correct this issue.\r\n\r\nI'm not sure why it doesn't work as it was written. I don't believe the PR should cause a different result, but it works and preserves the benefits of using ObjectID and the '*' option for devicestatus."}}
{"actor":{"display_login":"jpcunningh"}}