garth icon indicating copy to clipboard operation
garth copied to clipboard

Add additional metrics - Hill + Endurance score, Morning Training Readiness

Open vactomas opened this issue 6 months ago • 3 comments

Hi, matin, I've added a couple of additional metrics, which can be obtained from the Garmin API. I believe they could be of use to people, who process the data themselves.

Let me know, what you think!

Summary by CodeRabbit

  • New Features

    • Added support for retrieving Garmin fitness scores and morning training readiness data (single-date and range queries).
  • Documentation

    • README expanded with usage examples and detailed fields for Garmin Scores and Morning Training Readiness (note: example sections were duplicated in the README).
  • Tests

    • New tests verifying get/list behavior and key fields for Garmin Scores and Morning Training Readiness.

vactomas avatar Jul 11 '25 14:07 vactomas

Walkthrough

Adds two new data models, GarminScoresData and MorningTrainingReadinessData, exposes them in package exports, adds README examples (duplicated), and includes tests for their get() and list() methods. No runtime API signatures were changed.

Changes

Cohort / File(s) Change Summary
Documentation
README.md
Added examples for "Additional Garmin Scores" and "Morning Training Readiness" (duplicated blocks).
Package exports
src/garth/__init__.py, src/garth/data/__init__.py
Exported and imported GarminScoresData and MorningTrainingReadinessData.
Garmin scores model
src/garth/data/garmin_scores.py
New GarminScoresData dataclass with get() (merges hill & endurance endpoints, camel->snake keys) and list() (sorted by calendar_date).
Morning readiness model
src/garth/data/morning_training_readiness.py
New MorningTrainingReadinessData dataclass with get() (filters inputContext=="AFTER_WAKEUP_RESET", camel->snake) and list() (sorted by calendar_date).
Tests
tests/data/test_garmin_scores.py, tests/data/test_morning_training_readiness.py
New pytest cases (vcr) for get() and list() behaviors, including date-with-no-data checks.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as User/Test
    participant SDK as garth.client
    participant API as Garmin API

    Caller->>SDK: GarminScoresData.get(date)
    SDK->>API: GET /wellness-api/score/hills/{date}
    API-->>SDK: hill score payload (camelCase)
    SDK->>API: GET /wellness-api/score/endurance/{date}
    API-->>SDK: endurance payload (camelCase)
    SDK->>SDK: camel_to_snake_dict, rename keys, merge
    SDK-->>Caller: GarminScoresData instance or None

    Caller->>SDK: MorningTrainingReadinessData.get(date)
    SDK->>API: GET /metrics-service/metrics/trainingreadiness/{date}
    API-->>SDK: readiness payload (list)
    SDK->>SDK: select entry where inputContext=="AFTER_WAKEUP_RESET"
    SDK->>SDK: camel_to_snake_dict, construct dataclass
    SDK-->>Caller: MorningTrainingReadinessData instance or None

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • matin/garth#116 — Similar changes updating package exports (src/garth/__init__.py, src/garth/data/__init__.py) to add new data classes.

Suggested reviewers

  • matin
  • felipao-mx
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a 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.

❤️ Share
🪧 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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

coderabbitai[bot] avatar Jul 11 '25 14:07 coderabbitai[bot]

Codecov Report

:x: Patch coverage is 99.25926% with 1 line in your changes missing coverage. Please review. :white_check_mark: Project coverage is 99.95%. Comparing base (4b027e1) to head (5d23551).

Files with missing lines Patch % Lines
src/garth/data/morning_training_readiness.py 97.82% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #135      +/-   ##
===========================================
- Coverage   100.00%   99.95%   -0.05%     
===========================================
  Files           45       49       +4     
  Lines         1898     2028     +130     
===========================================
+ Hits          1898     2027     +129     
- Misses           0        1       +1     
Flag Coverage Δ
unittests 99.95% <99.25%> (-0.05%) :arrow_down:

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.

codecov[bot] avatar Aug 19 '25 01:08 codecov[bot]

@vactomas both of your PRs have the same issue. let's put pragma: no cover.

you could also mock the response, but don't worry about it. let's get these PRs merged

matin avatar Aug 19 '25 03:08 matin