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

Upload treatments to multiple Nightscout servers #3362

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Navid200
Copy link
Collaborator

@Navid200 Navid200 commented Feb 25, 2024

Fixes: #266

We have had an open issue (see above link) for 6 years where sensor start/stop or treatments are only uploaded to the first server if we have more than one.

This PR fixes that.
I have tested entering treatments and starting and stopping and deleting treatments. they all are reflected on both servers after this PR.

However, I must say that I am not closing the queue. I have commented it out.
I am sorry I am not sure the negative side effect of that if any!
So, please review this taking my inexperience into account.

@jamorham
Copy link
Collaborator

jamorham commented Apr 7, 2024

I haven't fully reviewed these code paths but this looks like it would create infinitely repeating uploads

@Navid200
Copy link
Collaborator Author

Navid200 commented Apr 12, 2024

We have a main (outside) loop that goes over all URLs here:



Every time we go through this loop (every URL), this line is executed:

doRESTUploadTo(nightscoutService, hashedSecret, glucoseDataSets, meterRecords, calRecords);


That line uploads readings, calibrations and treatments. But, only for treatments, there is a loop created here:



Therefore, this loop is inside the first loop I pointed out.
In other words, for every URL, we have to go through this loop for uploading treatments.

But, there are several instances inside this internal loop that upon fail or success, the queue is completed like this as an example:



The problem is that when the time comes for the outside loop to increment to the next URL, this queue is not recreated.
That's why the treatments are only uploaded to the first URL.

I removed the queue terminations. When testing, I have not noticed an infinite upload.

I admit that I have not resolved this gracefully. But, I want this resolved so that we can close an issue that has been open for 6 years.
How can I proceed to do this right?

@Navid200 Navid200 marked this pull request as draft April 21, 2024 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload of "eventType: Sensor Start" to the Nightscout treatments works only to 1st NS site
2 participants