feat: auto-chunk breathing rate and HRV date ranges > 30 days - #49
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds automatic date-range chunking for Breathing Rate and HRV API calls so requests spanning more than 30 days are split into multiple <=30-day requests and then aggregated, preventing Fitbit API errors for long ranges.
Changes:
- Added a private helper in
FitbitAPIto fetch and aggregate multi-chunk responses for long date ranges. - Updated Breathing Rate (summary + intraday) and HRV (summary) endpoints to use the chunking helper.
- Bumped package version and added unit tests covering single-date, <=30-day, and multi-chunk scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
fitbit_cli/fitbit_api.py |
Introduces _fetch_chunked_data() and routes br/hrv endpoints through it to support ranges > 30 days. |
fitbit_cli/__init__.py |
Version bump to 1.9.0. |
tests/date_range_test.py |
Adds unit tests validating request chunking behavior and aggregation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Preserve top-level metadata fields from first response chunk in _fetch_chunked_data - Add exact call count assertion to multi-chunk date range test Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
Addressed both Copilot review suggestions:
All unit tests (35/35) and linters ( |
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.
Overview
Fixes #35 by implementing automatic chunking for date ranges > 30 days for Breathing Rate and HRV endpoints using Claude Code CLI (gemini/gemini-3.6-flash model via gateway).
Changes
fitbit_cli/fitbit_api.py: Added private helper_fetch_chunked_data(self, url_template, key, start_date, end_date=None)to automatically split ranges > 30 days into <= 30-day windows, fetch each chunk, and aggregate response lists (brandhrv).fitbit_cli/__init__.py: Bumped version to1.9.0.tests/date_range_test.py: Added unit tests for single date, <= 30 day range, and multi-chunk > 30 day range.How to Test
git fetch origin git checkout feat/auto-chunk-date-range pip3 install -e . fitbit-cli -b last-2-months fitbit-cli -H last-3-months