Skip to content

Conversation

@krystophv
Copy link
Member

@krystophv krystophv commented Nov 12, 2025

Improves pump settings selection for date-bounded reports by aligning to the latest in-range insulin upload Ensures corresponding upload records are fetched when missing to keep device context accurate Extracts alignment logic into a testable helper and adds unit coverage for boundary cases

Partnered with viz PR tidepool-org/viz#559 for WEB-3916

Relates to BACK-3250

Improves pump settings selection for date-bounded reports by aligning to the latest in-range insulin upload
Ensures corresponding upload records are fetched when missing to keep device context accurate
Extracts alignment logic into a testable helper and adds unit coverage for boundary cases

Relates to BACK-3250
Copilot AI review requested due to automatic review settings November 12, 2025 21:27
Copilot finished reviewing on behalf of krystophv November 12, 2025 21:31
Copy link

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 improves pump settings selection for date-bounded reports by aligning them with the latest in-range insulin data rather than simply fetching the most recent pump settings. The refactoring extracts the alignment logic into a static, testable helper method and adds comprehensive unit tests for boundary cases.

Key changes:

  • Introduces getLatestInsulinAndPumpSettingsParams static method to identify the latest in-range insulin datum (basal/bolus) and generate appropriate pump settings fetch parameters
  • Implements a fallback strategy: first attempts to fetch pump settings aligned with insulin data, then falls back to the latest pump settings within the date range if no aligned data exists
  • Adds unit tests covering successful alignment and the null case when no in-range insulin data exists

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/report.mjs Adds static helper method for insulin-aligned pump settings selection and refactors generate() method to use the new alignment strategy with fallback logic; includes minor style fixes (trailing comma, semicolon, import ordering)
test/report.test.js Adds two test cases for the new static method covering successful pump settings param generation and null return when no in-range insulin data is found

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Aligns pump settings lookup to the latest in-range pump data for continuous datasets and to upload time for non-continuous datasets to better match visualisation behavior.
Passes through only supported metadata needed for downstream settings alignment and corrects a minor comment typo.
Extends tests to cover new bounding rules and validate behavior across dataset types.
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