-
-
Notifications
You must be signed in to change notification settings - Fork 279
Add activities count endpoint and method to retrieve total activities #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning
|
| Cohort / File(s) | Summary |
|---|---|
New API surface for activities count garminconnect/__init__.py |
Added public attribute garmin_connect_activities_count containing the endpoint URL and new method count_activities() which requests the endpoint, validates response presence, and returns totalCount or raises GarminConnectConnectionError on missing data. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant GarminClass as Garmin
participant API as Garmin API
Client->>GarminClass: call count_activities()
GarminClass->>API: HTTP GET garmin_connect_activities_count
alt API returns JSON with totalCount
API-->>GarminClass: { totalCount: N, ... }
GarminClass-->>Client: return N
else API returns empty/invalid
API-->>GarminClass: {} / null
GarminClass-->>Client: raise GarminConnectConnectionError
end
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
- Verify extraction of
totalCountand its type/validation - Check error raising (GarminConnectConnectionError) path when response missing
- Confirm the endpoint URL value assigned to
garmin_connect_activities_count
Poem
🐰 A curious rabbit counts each run,
Hops to an endpoint in morning sun,
Fetches a number, returns it bright,
If silence comes, it raises a plight,
Hooray — totals found, the tally's done!
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The PR title "Add activities count endpoint and method to retrieve total activities" accurately summarizes the main changes in the changeset. The title clearly identifies both key additions: the new endpoint URL attribute (garmin_connect_activities_count) and the new method (count_activities()). The title is concise, specific, and uses clear language without vague or generic terms. A teammate scanning the repository history would immediately understand that this PR adds functionality to retrieve the total count of activities, which aligns with the stated PR objective of providing the total activities count for better use of pagination parameters. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
garminconnect/__init__.py(2 hunks)
🔇 Additional comments (1)
garminconnect/__init__.py (1)
243-243: LGTM! Endpoint URL follows existing conventions.The new endpoint URL is consistent with other activity-related endpoints and follows the established naming pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
garminconnect/__init__.py (1)
1522-1531: Excellent implementation - past review feedback incorporated.The defensive check suggested in the previous review has been implemented correctly. The method follows the established patterns in the codebase (similar to
get_device_solar_dataon Line 1496) and handles error cases appropriately.Optional type safety enhancement:
While the current implementation is consistent with the rest of the codebase, you could add validation that
totalCountis actually an integer and not None to ensure the return type guarantee:activities_count = self.connectapi(url) if not activities_count or "totalCount" not in activities_count: raise GarminConnectConnectionError("No activities count data received") + + total_count = activities_count["totalCount"] + if not isinstance(total_count, int): + raise GarminConnectConnectionError(f"Unexpected totalCount type: {type(total_count)}") + - return activities_count["totalCount"] + return total_countThis would protect against unexpected API responses, though it's not done elsewhere in the codebase, so this is purely optional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
garminconnect/__init__.py(2 hunks)
🔇 Additional comments (1)
garminconnect/__init__.py (1)
243-243: LGTM! Endpoint URL follows established patterns.The new
garmin_connect_activities_countendpoint is correctly placed alongside the related activities endpoints and follows the naming conventions used throughout the class.
|
@Tourniercy thank you for this PR! |
PR to add a activities count endpoint
So we can have the total activities and use the start and the limit from get_activities endpoint with more knowledge
Summary by CodeRabbit