Skip to content

Use SportTypesEnum instead of strings for mode/kind/sport#97

Merged
luigi311 merged 1 commit intomainfrom
activity_type
Feb 28, 2026
Merged

Use SportTypesEnum instead of strings for mode/kind/sport#97
luigi311 merged 1 commit intomainfrom
activity_type

Conversation

@luigi311
Copy link
Owner

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces string-based sport/mode identifiers with a shared SportTypesEnum, and persists the sport type in the DB so exports/uploads/UI can rely on explicit metadata instead of inference.

Changes:

  • Introduces SportTypesEnum plus a new activity_sport table, and persists sport type at activity creation time.
  • Updates UI flow (mode select, free run, workout views) and recorder initialization to pass sport_type instead of string kind/profile.
  • Updates TCX export + Intervals.icu upload/history rendering to use sport_type (with inference as a fallback for older activities).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/fitness_tracker/upload_providers/intervals_icu.py Uses persisted ActivitySport/SportTypesEnum (fallback to inference) when uploading.
src/fitness_tracker/ui_workout.py Replaces kind: str with sport_type: SportTypesEnum for workout display/metrics.
src/fitness_tracker/ui_tracker.py Propagates sport_type through navigation, sensor settings, and view construction.
src/fitness_tracker/ui_mode.py Switches mode selection to SportTypesEnum and updates labels/callback signatures.
src/fitness_tracker/ui_history.py Stores/uses sport_type in summaries and export naming/rendering.
src/fitness_tracker/ui_free_run.py Replaces kind: str with sport_type: SportTypesEnum for free run metrics.
src/fitness_tracker/ui.py Replaces profile-string sensor selection with sport_type and passes it into Recorder.
src/fitness_tracker/recorder.py Recorder now carries sport_type and persists it on start_activity().
src/fitness_tracker/exporters.py TCX export and sport inference now operate on SportTypesEnum.
src/fitness_tracker/database.py Adds SportTypesEnum, ActivitySport, and persists sport type during start_activity().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@luigi311 luigi311 force-pushed the activity_type branch 2 times, most recently from 3e53c05 to 0504b21 Compare February 28, 2026 05:31
@luigi311 luigi311 requested a review from Copilot February 28, 2026 05:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

src/fitness_tracker/ui_history.py:388

  • In the SportTypesEnum.biking branch, primary, cadence_vals, and power_vals are assigned twice in a row (duplicate block). This duplication makes the code harder to maintain and is easy to accidentally diverge; remove the repeated assignments.
                elif sport_type == SportTypesEnum.biking:
                    primary = cycles
                    cadence_vals = [
                        float(c.cadence_rpm) for c in cycles if c.cadence_rpm is not None
                    ]
                    power_vals = [float(c.power_watts) for c in cycles if c.power_watts is not None]
                    primary = cycles
                    cadence_vals = [
                        float(c.cadence_rpm) for c in cycles if c.cadence_rpm is not None
                    ]
                    power_vals = [float(c.power_watts) for c in cycles if c.power_watts is not None]

src/fitness_tracker/ui_tracker.py:528

  • When a workout completes, the view is switched to FreeRunView using sport_type, but the page title is still hard-coded to "Free Run". This will be incorrect for biking workouts; set the title based on sport_type (similar to _show_free_run_page).
            self.free_view = FreeRunView(self.app, sport_type=sport_type)
            self.free_view.btn_stop.connect("clicked", lambda *_: self._stop_run_and_back())
            # Replace the top page: pop workout, push free-run
            if self.nav:
                self.nav.pop()
                self._push(self.free_view, "Free Run")
                self.free_view.set_recording(True)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Luis Garcia <git@luigi311.com>
@luigi311 luigi311 changed the title Use SportTypeEnum instead of strings for mode/kind/sport Use SportTypesEnum instead of strings for mode/kind/sport Feb 28, 2026
@luigi311 luigi311 merged commit b0222b8 into main Feb 28, 2026
6 checks passed
@luigi311 luigi311 deleted the activity_type branch February 28, 2026 05:40
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.

2 participants