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

duplication of SMB ratio for tags #4

Merged
merged 2 commits into from
Mar 17, 2024
Merged

Conversation

mountrcg
Copy link
Contributor

@mountrcg mountrcg commented Mar 6, 2024

Some duplication that leads to a repeated tag in popup and also missaligns the popup, due to conclusion semicolon in wrong place.

bug solution
Simulator Screenshot - iPhone 15 Pro - 2024-03-06 at 00 37 07 Simulator Screenshot - iPhone 15 Pro - 2024-03-06 at 00 42 33

has already been added to tddReason way before
@mountrcg
Copy link
Contributor Author

mountrcg commented Mar 6, 2024

I would suspect that more of those foul easter eggs can be hidden in oref.

I can't test that thoroughly as I am on a completely different oref and iAPS branch. But this bug would have been very obvious to everyone using a different SMB ratio (!=0.5) in iAPS, if that oref-release would have been used in minimized version.

@bjornoleh
Copy link
Contributor

Perhaps we should look for duplicate code in determine-basal after inclusion of findings from 05a1a2e

That would probably have caught this. Can someone check this?

@bjornoleh
Copy link
Contributor

Here are the lines that were included from minimised files in 05a1a2e

https://github.com/nightscout/open-iaps-oref/blob/97b012ab8e8f0062cecc9d2e02d915ef0124cd2e/lib/determine-basal/determine-basal.js#L756-L758

It is not exactly the same as the lines that ended up as duplicate code and suggested to be removed by @mountrcg

https://github.com/nightscout/open-iaps-oref/blob/97b012ab8e8f0062cecc9d2e02d915ef0124cd2e/lib/determine-basal/determine-basal.js#L1573-L1576

It looks like the duplication is caused by this line, where tddReason is appended to rT.reason, which already includes SMB Ratio:
https://github.com/nightscout/open-iaps-oref/blob/97b012ab8e8f0062cecc9d2e02d915ef0124cd2e/lib/determine-basal/determine-basal.js#L1571

I agree we must remove the duplicate code, while ensuring this works as expected. Perhaps @JeremyStorring could take a look here?

Specifically, I wonder why the printed SMB Ratio is capped at 1 by Math.min(profile.smb_delivery_ratio, 1). There may be reasons to limit smb_delivery_ratio, but capping the output to enacted/suggested would only lead to false information if the setting was actually higher than 1?

@bjornoleh
Copy link
Contributor

I think cd1aa93 is the correct approach for now. We may also want to introduce a real limit to avoid setting smb_delivery_ratio, but I have not looked into where that should happen.

Currently, any value for smb_delivery_ratio is accepted, which can let the app issue SMBs that are larger than insulinReq (SMB = insulinReq * smb_delivery_ratio, unless otherwise restricted by SMB basal minutes or max bolus). This is in no way in line with the original oref0.

@mountrcg
Copy link
Contributor Author

I think cd1aa93 is the correct approach for now. We may also want to introduce a real limit to avoid setting smb_delivery_ratio, but I have not looked into where that should happen.

Currently, any value for smb_delivery_ratio is accepted, which can let the app issue SMBs that are larger than insulinReq (SMB = insulinReq * smb_delivery_ratio, unless otherwise restricted by SMB basal minutes or max bolus). This is in no way in line with the original oref0.

I agree, capping should be done in Settings or while applying the SMB ratio, as done for many other settings in oref. I would prefer to have that done while defining the setting. I actually know people who use SMB ratio > 1, they would be really hooped with the current implementation.

@bjornoleh
Copy link
Contributor

bjornoleh commented Mar 14, 2024

I will drop the above commit to keep the limit for logs/output while (re-)introducing the missing max limit for smb_ratio:

-            var smb_ratio = profile.smb_delivery_ratio;
+            var smb_ratio = Math.min(profile.smb_delivery_ratio, 1);

Together with this, the limit of max 1 is functional:

https://github.com/nightscout/open-iaps-oref/blob/975245b2adcc17d51b45c4cbd6e2f765d55e23f1/lib/determine-basal/determine-basal.js#L756-L758

@bjornoleh
Copy link
Contributor

After locally merging devinto this branch, and building OiAPS based on the minimised js, I have confirmed that SMB ratio is limited to max 1 by the above changes, both in enacted and in the actually delivered SMBs. And the tags that this PR originally targeted fixing still look good.

@bjornoleh
Copy link
Contributor

@JeremyStorring , I think this should be good now. Could you give a review, and then we can probably merge with dev? Thanks!

@JeremyStorring
Copy link
Contributor

Everything looks good here! No further changes required :)

@JeremyStorring JeremyStorring merged commit f932754 into dev Mar 17, 2024
@MikePlante1 MikePlante1 deleted the duplicate_SMBratio branch May 4, 2024 14:23
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.

None yet

3 participants