Skip to content

[WEB-4406] - Fix Insulin Averaging due to Partial Days#595

Open
henry-tp wants to merge 7 commits intorelease-1.55.0from
WEB-4406-insulin-calc
Open

[WEB-4406] - Fix Insulin Averaging due to Partial Days#595
henry-tp wants to merge 7 commits intorelease-1.55.0from
WEB-4406-insulin-calc

Conversation

@henry-tp
Copy link
Contributor

@henry-tp henry-tp commented Feb 16, 2026

@henry-tp henry-tp changed the title WEB-4406 use 24-hour bucketing instead of whole-day bucketing WEB-4406 - Fix Insulin Calculations Undercounting due to Partial Days Feb 16, 2026
@henry-tp henry-tp changed the title WEB-4406 - Fix Insulin Calculations Undercounting due to Partial Days WEB-4406 - Fix Insulin Averaging due to Partial Days Feb 17, 2026
@henry-tp henry-tp marked this pull request as ready for review February 17, 2026 21:48
@henry-tp henry-tp requested a review from krystophv February 18, 2026 20:24
@henry-tp henry-tp changed the title WEB-4406 - Fix Insulin Averaging due to Partial Days [WEB-4406] - Fix Insulin Averaging due to Partial Days Feb 18, 2026
@krystophv krystophv requested a review from Copilot February 18, 2026 20:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@henry-tp henry-tp changed the base branch from develop to release-1.55.0 February 25, 2026 19: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.

2 participants