-
Notifications
You must be signed in to change notification settings - Fork 395
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
Some openAPS treatments appearing as future dated in Nightscout reports for Australia timezone #600
Comments
I looked into this a while back - at the time I came to the conclusion that it was because OpenAPS uploads treatments in local time (i.e. +10 in Sydney). Might be a change required to https://github.com/openaps/oref0/blob/dev/bin/nightscout.sh to upload using a timestamp converted to UTC? |
Did you see it on all entries - I just have it happening with treatments from early afternoon and evening? |
Only with treatments after 2 pm. During daylight savings it's treatments after 1 pm. Which is consistent with the time difference of +10/+11. Is that what you see? At the time we were switching over from Loop to OpenAPS. Loop treatments displayed fine, which suggested that it was the OpenAPS upload procedure that was at fault - not NS itself. |
Yes that sounds the same as what I see - it's been like it since I setup in Dec. We haven't tried loop to compare it with.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Paul Dickens <[email protected]>
Sent: Sunday, August 13, 2017 10:49:03 AM
To: openaps/oref0
Cc: Mel Clegg; Author
Subject: Re: [openaps/oref0] Some openAPS treatments appearing as future dated in Nightscout reports for Australia timezone (#600)
Only with treatments after 2 pm. During daylight savings it's treatments after 1 pm. Which is consistent with the time difference of +10/+11. Is that what you see?
At the time I we were switching over from Loop to OpenAPS. Loop treatments displayed fine, which suggested that it was the OpenAPS upload procedure that was at fault - not NS itself.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#600 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AHs1YDDLeQufIoeZlTGGFQ7Dly3oYmc0ks5sXkf_gaJpZM4O1ise>.
|
@thebookins :the fix must not be in the |
Thanks @PieterGit , I knew we'd been over this before. I see that your PR wasn't pulled; do you think that |
Yes, we need the JSON command to convert |
Nightscout stores treatments in UTC format. Nightscout find uses string compare for $gte, so: - all treatments `created_at` fields must be set in UTC format - all treatments must be queried in UTC format I noticed also that `settings/temptargets.json` is queried in local time and not using a UTC, which I believe is a bug, because Nightscouts stores the `created_at` for temp targets in UTC format and Mongo `$gte` compare compares strings (and doesn't use the timezone). This also fixes problems with false positive future treatments in Nightscout. Installation ``` cd ~/src mv oref0 oref0.openaps git clone https://github.com/PieterGit/oref0.git cd oref0 git checkout 201708_treatments npm run global-install rerun oref0-setup.sh or ~/myopenaps/oref0-runagain.sh ``` Please test on a seperate spare rig. I will now test it myself. The branch is based on the dev / 0.5.3 branch
@thebookins I just created a pull request #612 BUT BE CAREFULL: I'm seeing duplicate carbs because the mongodb will have both the @scottleibrand do you know a proper way to add the necessary unduplication code, so that carbs/treatments that are in TIMESTAMP+TZ format are ignored by oref0. I-to-b discussion is at https://gitter.im/nightscout/intend-to-bolus?at=5992076e614889d4754a04ba |
We might want to avoid cross-tz deduplication, and instead just force oref0 to ignore treatments with a non-UTC timezone at the same time we switch it to upload in UTC. We'd still need a compatibility warning not to run older rigs alongside newer ones, though, which probably means this would be best targeted for 0.6.0. |
I agree that completely switch to ignore treatments with a non-UTC timezone should be targeted at 0.6.x. But I think we can make an easier upgrade path by:
That way a 0.5.3 rig and 0.6.x rig can still work together fine. For 0.6.x I think we must also must convert Help is needed/wanted. I think that we must make a working solution for all the |
Note that this issue is not only related to Australia, but to all |
@PieterGit converting all date strings to ISO should solve the duplication issue, but I think this change will still cause some disruption since MongoDB will have treatments using the old local timezone and the query we are using does a simple string compare. I guess we could write a python script that crawls over the database and converts all created_at fields, but users would need to remember to do this before updating. |
The suggestion I make is for 0.5.3 to always convert the |
IMO these changes are all too complicated for 0.5.3, but would be reasonable for 0.6.0. If we want to do something for the 0.5.3 patch release, I think it should be limited to (for example) extending the query duration from 6 hours to ~ 18 hours so that the timezone-blind string comparison doesn't miss anything. Even that would require some testing, though, so if we want to make that change we should do so soon. |
This is something you could potentially use momenjs for potentially |
Might be easier to just make ns do a conversion on created_at if not in utc |
👍 for a longer look back as a short term patch |
One of you Aussies or Kiwis want to test out the different lookback durations and see what works well for you, and then prep a PR to change it so the rest of us can test? |
@scottleibrand I'm happy to do that. |
@scottleibrand : after a good night of sleep I must admit that converting to UTC / unduplicating the created_at timestamps in 0.5.3 is too risky and must be postponed to 0.6.x. I don't see how I can retarget #612 to 0.6.0-dev. Can you do that for me? Or can you change the oref0 github settings so that authors can retarget their own PR's themselves? I also tried how we should ignore non-UTC @stavlor : I agree momentjs is cool and it's used in oref0 on other places, but I don't think it has any advantages to plain Javascript like: |
@PieterGit just curious, any reason for wrapping |
I think you're right, see https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.3.2 or https://www.ecma-international.org/ecma-262/8.0/index.html#sec-date-value (ECMAScript v8): "parsing v as a date, in exactly the same manner as for the parse method" I couldn't find good documentation on the Date constructor and Date.parse worked so I didn't look further. |
In my experience it's good to be lenient in what data is ingested and strict what data is output; look like a good related improvement would be to add code to the Nightscout API that ensured all dates are normalized to UTC upon input, before inserting to MongoDB. |
Temporary fix in #614 to get temp targets and carb histories working again for everyone at UTC +x. |
@sulkaharo @thebookins : i created a patch for Nightscout which converts the This follows https://en.wikipedia.org/wiki/Robustness_principle / Postel's law "Be conservative in what you send, be liberal in what you accept". The branch is based on @sulkaharo branch nightscout/cgm-remote-monitor#2736 and can be found here: https://github.com/PieterGit/cgm-remote-monitor/tree/treatments_utc Please test this Nightscout branch and check to see if all COB's and created_at timestamps are fine. I tested in on a 0.5.3 rig, and can't find any problems with this Nightscout solution. |
@sulkaharo @PieterGit @scottleibrand I just noticed that autotune uses a local timezone string compare to filter
If I'm not mistaken, this will need to be changed to UTC with nightscout/cgm-remote-monitor#2763. This also means that currently autotune won't be getting all of the carb info if some of it was entered through NS (with UTC timestamp). Would much of this messiness be resolved by storing |
I believe I fixed the autotune timezone issue in 0.6.0-dev. Are there any remaining issues here we want to actively work on fixing? Or are we happy with the fixes in place for now? |
The issue is not affecting all openAPS generated entries - just ones that are created from the afternoon period onwards.
The text was updated successfully, but these errors were encountered: