Add rename function option to return activity ID from uploaded activity
Resolves #88.
Not much to describe apart from the PR title.
I modified upload() to use Client.request to be able to access the "location" response header, which contains the URL needed to fetch the activity ID of the uploaded file. This is not returned initially when the file is uploaded, as it takes Garmin some time to process the activity. I implemented a simple polling process to check if the ID is ready, backing off by half a second with each try. If it doesn't return the value within 5 tries, it gives up.
The headers include with the rename() implementation are what I found to be the minimum required, but I'm not very experienced with the Garmin API, so maybe you have a better implementation.
I also edited the readme to describe the new functionality with a demo.
Summary by CodeRabbit
- New Features
- Added ability to retrieve Garmin Connect activity ID after uploading an activity.
- Introduced method to rename activities on Garmin Connect.
- Documentation
- Updated README with new upload method usage and example code.
- Improvements
- Enhanced upload method with optional ID retrieval.
- Implemented retry mechanism for fetching activity ID.
- Noted potential delay in upload process due to server response time.
Walkthrough
The pull request introduces enhanced functionality for Garmin Connect activity management in the garth library. The changes focus on two main features: retrieving the internal activity ID after upload and renaming activities. The upload method now supports an optional return_id flag that allows users to obtain the Garmin-assigned activity identifier. A new rename method has been added to the Client class, enabling users to change the title of an uploaded activity directly through the library.
Changes
| File | Changes |
|---|---|
README.md |
Updated upload method example to demonstrate return_id functionality |
garth/http.py |
- Added return_id parameter to upload method- Implemented ID retrieval mechanism with retry logic - Added new rename method for changing activity titles |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Support renaming activities [#88] | ✅ | |
| Retrieve activity ID after upload [#88] | ✅ |
[!TIP]
⚡🧪 Multi-step agentic review comment chat (experimental)
- We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments. - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
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.Generate unit testing code for this file.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 generate unit testing code for this file.@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 generate unit testing code.@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.
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 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.
@coderabbitai full review
:white_check_mark: Actions performed
Full review triggered.