[WEB-4406] - Fix Insulin Averaging due to Partial Days#595
Open
henry-tp wants to merge 7 commits intorelease-1.55.0from
Open
[WEB-4406] - Fix Insulin Averaging due to Partial Days#595henry-tp wants to merge 7 commits intorelease-1.55.0from
henry-tp wants to merge 7 commits intorelease-1.55.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the insulin and carbohydrate averaging calculations that were previously counting calendar days instead of actual 24-hour periods from the first datum. This caused inaccurate averages when data was collected at times that didn't align with calendar day boundaries (e.g., starting at 8pm instead of midnight).
Changes:
- Replaced calendar day counting with 24-hour bucket calculation based on elapsed time from the first datum
- Applied the same fix to both insulin data (
getInsulinData()) and carbohydrate data (getCarbsData()) methods - Added comprehensive test coverage for partial-day and multi-day scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/StatUtil.js | Replaced calendar day counting logic with 24-hour bucket calculation in getInsulinData() and getCarbsData() methods; removed unused formatLocalizedFromUTC import |
| test/utils/StatUtil.test.js | Added comprehensive test cases for both insulin and carbs data covering partial-day and multi-day scenarios |
| package.json | Updated version from 1.55.0-web-4384-date-mismatch.5 to 1.55.0-web-4406-insulin-calc.1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WEB-4406
For further context: https://tidepoolteam.slack.com/archives/C09AWCB4Y/p1770862343039929
Blip: tidepool-org/blip#1872