garth icon indicating copy to clipboard operation
garth copied to clipboard

feat: `Activity` dataclass

Open juvilius opened this issue 1 year ago • 4 comments

and ci: dependency group instead of optional dependency for linting

I've had some troubles pleasing mypy, so please check if I've made a mistake before considering to merge. :)

Also: your Data class is focused on there being one of "it" per day. I'm not sure how to best reconcile it with activities.

Summary by CodeRabbit

  • New Features

    • Added Activity class to data module, enabling retrieval and management of activity information
    • Introduced new utility functions for processing dictionary keys
  • Chores

    • Updated linting configuration with specific dependency versions
    • Refined project dependency management
  • Refactor

    • Improved type checking and code organization
    • Enhanced data handling utilities

juvilius avatar Dec 30 '24 10:12 juvilius

Walkthrough

This pull request introduces enhancements to the project's data handling and utility functions, focusing on activity tracking and dependency management. The changes include adding a new Activity class in the data module, introducing utility functions for processing dictionary keys, and updating the project's configuration. The Makefile is modified to use a specific linting group, and the project's dependency management is refined with a new dependency group for linting tools.

Changes

File Change Summary
Makefile Modified lint target to use uv run --group linting mypy $(sources)
garth/data/__init__.py Added Activity to __all__ and imported from .activity
garth/data/activity.py Added new data classes: ActivityType, Summary, and Activity
Implemented methods for activity data retrieval and processing
garth/utils.py Added remove_dto and remove_dto_from_dict utility functions
pyproject.toml Added [dependency-groups] section with linting dependencies

Sequence Diagram

sequenceDiagram
    participant Client
    participant Activity
    participant HTTPClient
    
    Client->>Activity: list() or get(id)
    alt list activities
        Activity->>HTTPClient: Fetch activities
        HTTPClient-->>Activity: Return activity data
        Activity->>Activity: Sort activities
    else get specific activity
        Activity->>HTTPClient: Fetch activity by ID
        HTTPClient-->>Activity: Return activity details
        Activity->>Activity: Process and convert data
    end
    Activity-->>Client: Return Activity instance(s)

This sequence diagram illustrates the high-level interaction for retrieving activity data, showing how the Activity class interacts with an HTTP client to fetch and process activity information.

[!TIP] CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 @coderabbitai in 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 @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 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

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[bot] avatar Dec 30 '24 10:12 coderabbitai[bot]

@juvilius I apologize for not getting around to reviewing earlier. do you want to rebase, add tests and submit the changes?

adding this endpoint makes sense, especially to make available in garth-mcp-server

matin avatar May 27 '25 23:05 matin

Hi, @juvilius, Is there anything I could help you with in order to get this PR ready? I could use this feature for my personal project as well.

vactomas avatar Jul 07 '25 13:07 vactomas

Hi @matin,

sorry for the holdup. Let me explain. I had modified garth enough to be able to generate a map of my running tracks. To not have to rely on Garmin, I stored everything in a postgres DB. I therefore had to create a data model, which turned out to be a bother with Activities coming in all different shapes and sizes depending on the type of activity and even on the device/watch. This lead me to lazily store everything as JSON and hardcode only a handful of fields.

Long story short, I don't know how to easily collect every possible field for all types of activity in a dataclass. If anybody has an idea, go ahead :)

juvilius avatar Sep 07 '25 10:09 juvilius