Skip to content

Add get_scheduled_workouts_by_year_and_month to demo and API#343

Open
hab wants to merge 2 commits intocyberjunky:masterfrom
hab:master
Open

Add get_scheduled_workouts_by_year_and_month to demo and API#343
hab wants to merge 2 commits intocyberjunky:masterfrom
hab:master

Conversation

@hab
Copy link
Copy Markdown

@hab hab commented Apr 3, 2026

Add endpoint to retrieving schedules workouts by year and month.

Summary by CodeRabbit

  • New Features
    • Added a menu option to retrieve scheduled workouts by year and month. Prompts for year/month with input validation and displays matching scheduled workouts in an organized view for easy review of a selected time period.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d365cf68-114c-4f4d-84dc-b56f37ce41cb

📥 Commits

Reviewing files that changed from the base of the PR and between e2567d2 and 6da85bb.

📒 Files selected for processing (1)
  • garminconnect/__init__.py

Walkthrough

Added a new Garmin client method to fetch scheduled workouts by year and month, plus a demo UI menu option and handler that collect and validate year/month and call the client method.

Changes

Cohort / File(s) Summary
Demo UI
demo.py
Added menu option u under "🏃 Activities & Workouts". Added get_scheduled_workouts_by_year_and_month(api: Garmin) which prompts for year and month, validates non-empty input and integer conversion, and invokes call_and_display with the API call metadata. Updated execute_api_call dispatch to include the new handler.
Garmin API Client
garminconnect/__init__.py
Added self.garmin_calendar = "/calendar-service" and derived self.garmin_scheduled_workouts_url. Implemented Garmin.get_scheduled_workouts_by_year_and_month(year, month) that coerces to int, validates year (≥2000) and month (1–12), constructs the URL using month - 1 (0-indexed), logs debug, and calls self.connectapi(url).

Sequence Diagram

sequenceDiagram
    actor User
    participant Demo as demo.py
    participant Client as GarminClient
    participant API as GarminAPI

    User->>Demo: Select menu option "u"
    Demo->>Demo: Prompt for year and month
    User->>Demo: Enter year and month
    Demo->>Demo: Validate inputs (non-empty, int)
    Demo->>Client: get_scheduled_workouts_by_year_and_month(year, month)
    Client->>Client: Coerce to int and validate (year ≥ 2000, 1 ≤ month ≤ 12)
    Client->>Client: Build URL (month - 1 → 0-indexed)
    Client->>API: GET /calendar-service/scheduled-workouts?year=...&month=...
    API-->>Client: Return scheduled workouts payload
    Client-->>Demo: Return response dict
    Demo-->>User: Display formatted results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes in the pull request, which adds a new function to retrieve scheduled workouts by year and month to both the demo and API.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@garminconnect/__init__.py`:
- Around line 2735-2737: The validation currently checks "if year < 2000" but
raises "year must be after 2000," which is misleading because 2000 is allowed;
update the ValueError message in the check that uses the variable year (the line
"if year < 2000: raise ValueError(f\"year must be after 2000, got: {year}\")")
to accurately reflect the boundary, e.g. "year must be >= 2000, got: {year}" or
"year must be 2000 or later, got: {year}".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 669d1ee7-474f-4624-b398-08ced4fb94dd

📥 Commits

Reviewing files that changed from the base of the PR and between c7fcade and e2567d2.

📒 Files selected for processing (2)
  • demo.py
  • garminconnect/__init__.py

@nevdull77 nevdull77 mentioned this pull request Apr 8, 2026
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.

1 participant