Use SportTypesEnum instead of strings for mode/kind/sport#97
Merged
Conversation
There was a problem hiding this comment.
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
SportTypesEnumplus a newactivity_sporttable, and persists sport type at activity creation time. - Updates UI flow (mode select, free run, workout views) and recorder initialization to pass
sport_typeinstead of stringkind/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.
3e53c05 to
0504b21
Compare
There was a problem hiding this comment.
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.bikingbranch,primary,cadence_vals, andpower_valsare 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
FreeRunViewusingsport_type, but the page title is still hard-coded to "Free Run". This will be incorrect for biking workouts; set the title based onsport_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>
0504b21 to
42b1999
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.