-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
G7 backfill overlap fix #3557
G7 backfill overlap fix #3557
Conversation
I thought I had solved the problem. But, further tests showed failure. |
I'm not sure whether this actually should look at the last sensor stop time and not backtrack before that rather than looking at when readings have been received? |
I don't understand your point. If we switch from a G6 transmitter to another, and the first one has not stopped yet, we should not overlap its readings. Did I misunderstand your point? |
The overlap actually uploads to Nightscout and AAPS. It is really bad. |
There are times a G7 user chooses to switch to their next G7 before their current 10.5 days are completed. |
If the sensor is stopped then there should not be any readings for the period while the sensor is stopped. Here we are activating the sensor and I'm thinking we should cap how far back we backtrack the start time of this sensor to not before the end of the previous sensor session. That is what my todo says. If you look only at the readings then you potentially are overlapping sensor periods which I think is the cause of the problem overall. So you can use |
If the previous session has never stopped in xDrip, your suggestion will fail to avoid a backfill overlap. This PR will avoid a backfill overlap under all possible conditions. |
I respectfully disagree. I didn't want to make this solution only for G7 because there have been reports of overlap even for G6. Can you tell me how this is ever going to allow an overlap? I have shown the different scenarios that can cause an overlap here: #3398 This PR avoids all of those. |
Let's say the user started their current G7 at 11:00 am 10 days ago. If I use last stopped, it will find the session that stopped 10 days ago. And there will be an overlap. Would you please tell me what I am overlooking? |
I am sorry that I misunderstood your TODO comment. Regardless, I believe this is the best solution. Please give me a scenario that you believe this PR will fail, and I will try to test exactly the scenario you are concerned about. Either I will learn that I am missing something and will change this PR back to draft, or I can show you that the scenario works fine after this PR and there should be no concern. |
So I think the situation is that with G7 and possibly with G6 we get that the xDrip sensor session is not tied to the actual sensor (eg if you change transmitter id) - This was not the original intention of the Sensor class but that dates back to G4 and where we did the algorithm internally. In that case you are correct that it is the readings we should be looking for. The only problem I can see is if we somehow got readings from elsewhere that were not yet synced (via follow perhaps) but I think that is very much an edge case where the user would have to try hard to break things and then they would likely only incorrectly fill in any open gaps in the data. |
Yes, I agree 100%. Gaps should be avoided. |
Please, please, don't ask for a switch! |
Thanks I will make an announcement on facebook after merge. |
I'm sorry I don't think this was a perfect solution. A problem I have is that after I test a PR and submit it, I will have to switch back to the latest official Nightly so that I can see what everyone else sees. I will have to open a new PR to address this and I am so sorry. |
Fixes: #3398
How to Recreate the problem
You will need a G7 session in progress and a test phone.
On the test phone, uninstall xDrip and install the latest Nightly (June 28, 2024).
If you have a G6 session in progress, establish connectivity to it. If you don't set up fake data source.
After establishing connectivity to your G6, wait for another read cycle so that it backfills the past 3 hours.
Now, stop the session. It is important to stop the xDrip session. There is no reason to stop the real session on G6.
After having stopped the xDrip session, change the transmitter ID to your G7 session in progress.
After establishing connectivity to G7, wait for another read cycle so that the backfill is completed. You will see that you will get a 24-hour backfill even though you have had 3 hours of readings from G6. So, you will end up with an overlap.
Tests
All tests were run on an Android 11 test phone.
1- Establishing connectivity to a G7 after a fresh install results in a 24-hour backfill.
2- Establishing connectivity to a G6 after a fresh install results in a 3-hour backfill.
3- Establishing connectivity to a G7 after having stopped a G6 session, a backfill takes place to fill only the empty time after the last G6 reading. In other words, it does not cause an overlap.