Add training status support
Summary
- Add DailyTrainingStatus, WeeklyTrainingStatus, MonthlyTrainingStatus classes
- Custom parsing logic for complex nested API responses
- Comprehensive test coverage with VCR cassettes
- Documentation in README with usage examples
API Endpoints Added
- Daily:
/mobile-gateway/usersummary/trainingstatus/latest/{date} - Weekly:
/mobile-gateway/usersummary/trainingstatus/weekly/{start}/{end} - Monthly:
/mobile-gateway/usersummary/trainingstatus/monthly/{start}/{end}
Implementation Details
- Follows existing patterns in the stats module for consistency
- Takes advantage of current base classes to keep code DRY
- Custom parsing logic handles the complex nested response structure
- All fields are properly typed with Pydantic dataclasses
Test Coverage
- 5 comprehensive tests covering daily, weekly, monthly endpoints
- Tests include pagination scenarios and edge cases
- VCR cassettes recorded for reliable test execution
Closes #129
π€ Generated with Claude Code
Summary by CodeRabbit
-
New Features
- Introduced support for retrieving daily, weekly, and monthly training status data, including new data classes and methods for each interval.
- Users can now access detailed training status metrics such as load, trends, feedback, and ACWR statistics for different periods.
-
Documentation
- Added comprehensive usage examples and sample outputs for training status retrieval to the documentation.
- Provided detailed developer guidance and architectural overview in a new contributor guide.
-
Tests
- Implemented extensive tests to ensure correct retrieval, parsing, and robustness of training status data, including edge and error cases.
"""
Walkthrough
This change introduces support for retrieving daily, weekly, and monthly training status data from the Garmin Connect API. It adds new dataclasses to model each interval, implements data extraction and pagination logic, updates public exports, extends documentation with usage examples, and provides comprehensive tests for the new functionality and edge cases.
Changes
| File(s) | Change Summary |
|---|---|
src/garth/stats/training_status/daily.py, weekly.py, monthly.py |
Added new dataclasses (DailyTrainingStatus, WeeklyTrainingStatus, MonthlyTrainingStatus) with API request logic, data extraction, and pagination for each training status interval. |
src/garth/stats/training_status/__init__.py |
Added __all__ and imported the three new training status classes for package-level export. |
src/garth/stats/__init__.py, src/garth/__init__.py |
Updated public API exports to include the new training status classes. |
README.md |
Added a "Training Status" section with usage examples and sample outputs for daily, weekly, and monthly training status retrieval. |
CLAUDE.md |
Added a guidance document for Claude Code, including architecture, coding patterns, and instructions for adding new stats endpoints. |
tests/stats/test_training_status.py |
Added new tests covering normal operation, edge cases, error handling, and pagination for the training status classes. |
src/garth/stats/_base.py |
Refactored Stats.list method to delegate API response parsing to a new _parse_response method, enabling subclasses to customize response handling. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant StatsClass as Daily/Weekly/MonthlyTrainingStatus
participant Client as HTTP Client
participant API as Garmin Connect API
User->>StatsClass: .list(end, period, client)
StatsClass->>Client: GET /mobile-gateway/usersummary/trainingstatus/{interval}/...
Client->>API: HTTP request
API-->>Client: JSON response
Client-->>StatsClass: Response data
StatsClass->>StatsClass: Extract and flatten data
StatsClass->>User: List of TrainingStatus objects
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
Implement daily training status retrieval (/mobile-gateway/usersummary/trainingstatus/latest/{date}) (#129) |
β | |
Implement weekly training status retrieval (/mobile-gateway/usersummary/trainingstatus/weekly/{start}/{end}) (#129) |
β | |
Implement monthly training status retrieval (/mobile-gateway/usersummary/trainingstatus/monthly/{start}/{end}) (#129) |
β |
Assessment against linked issues: Out-of-scope changes
| Code Change | Explanation |
|---|---|
Addition of CLAUDE.md (CLAUDE.md) |
This is a documentation file for Claude Code and not directly related to the training status feature. |
| """ |
π Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
π₯ Commits
Reviewing files that changed from the base of the PR and between 8ceb119ebaa8781c75ac9a2691684d83998f140f and dab68681cede95b96b4a857041255cb2f6042205.
β Files ignored due to path filters (5)
tests/stats/cassettes/test_daily_training_status.yamlis excluded by!tests/**/cassettes/**tests/stats/cassettes/test_monthly_training_status.yamlis excluded by!tests/**/cassettes/**tests/stats/cassettes/test_monthly_training_status_no_data.yamlis excluded by!tests/**/cassettes/**tests/stats/cassettes/test_weekly_training_status.yamlis excluded by!tests/**/cassettes/**tests/stats/cassettes/test_weekly_training_status_pagination.yamlis excluded by!tests/**/cassettes/**
π Files selected for processing (4)
README.md(1 hunks)src/garth/stats/_base.py(3 hunks)src/garth/stats/training_status/daily.py(1 hunks)tests/stats/test_training_status.py(1 hunks)
π§ Files skipped from review as they are similar to previous changes (3)
- README.md
- src/garth/stats/_base.py
- tests/stats/test_training_status.py
π§° Additional context used
πͺ Pylint (3.3.7)
src/garth/stats/training_status/daily.py
[refactor] 10-10: Too many instance attributes (23/7)
(R0902)
β¨ Finishing Touches
- [ ] π Generate Docstrings
π§ͺ Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Commit Unit Tests in branch
add-training-status - [ ] Post Copyable Unit Tests in Comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
πͺ§ Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
c1bdee8) to head (dab6868). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #130 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 43 48 +5
Lines 1793 2083 +290
==========================================
+ Hits 1793 2083 +290
| Flag | Coverage Ξ | |
|---|---|---|
| unittests | 100.00% <100.00%> (ΓΈ) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@coderabbitai review
β Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.