Skip to content

fix: keep existing workout step payloads unchanged, add target tests - #446

Merged
cyberjunky merged 2 commits into
masterfrom
fix/targeted-workout-cleanup
Sep 29, 2026
Merged

cyberjunky merged 2 commits into
masterfrom
fix/targeted-workout-cleanup

Conversation

@cyberjunky

@cyberjunky cyberjunky commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #440.

  • No change for existing steps: create_interval_step / create_distance_interval_step without targets upload exactly as before Add support for targeted workouts #440 again. The interval step and no.target displayOrder values are restored, and a no.target secondaryTargetType is no longer added to every step.

  • Cleanup: the two Protocol classes and per-class field redeclarations are replaced with shared _RangeTarget / _ZoneTarget base classes; IntensityTarget is now their union. The targeted helpers call the step functions directly, without type: ignore.

  • Docs: PaceTarget notes that limits are in m/s, so the slower pace is the lower limit.

  • Tests: new tests/test_workout_targets.py covers every target type, zone vs range targets, secondary targets, distance steps, limit validation, pace_to_mps / speed_to_mps, full workout serialization, and pins the untargeted step payload.

  • Demo: the running sample workout now has a pace target on its intervals (PaceTarget + pace_to_mps), and the cycling sample a 220-250 W power target with an 85-95 rpm cadence secondary target, so the demo upload options exercise the new helpers.

The payload for targeted steps is unchanged from #440, which was tested live by the contributor.

Summary by CodeRabbit

  • New Features
    • Workout interval targets now support validated range and zone targets, including power, heart-rate, speed, and pace targets.
    • Targeted time- and distance-based intervals accept these targets, including optional secondary targets.
  • Bug Fixes
    • Corrected interval step display ordering and preserved the distinction between an absent secondary target and an explicit no-target value.
    • Pace target documentation now clarifies that the lower limit represents a slower pace.

Follow-up to the targeted workouts support:
- Restore the interval step and no.target displayOrder values that were
  changed for all interval steps, and stop sending a no.target
  secondaryTargetType on every step; untargeted steps upload exactly as
  before again.
- Replace the Protocol classes and repeated field declarations with
  shared range/zone base classes, and drop the type: ignore in the
  targeted step helpers.
- Document that pace limits are in m/s (slower pace is the lower limit).
- Add tests for every target type, secondary targets, limit validation,
  the conversion helpers and the unchanged untargeted payload.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: cyberjunky/python-garminconnect/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 41b546a2-a1c9-4b6a-b913-40d3c0d3547f

📥 Commits

Reviewing files that changed from the base of the PR and between 406d263 and eb6f428.

📒 Files selected for processing (4)
  • garminconnect/workout.py
  • test_data/sample_cycling_workout.py
  • test_data/sample_running_workout.py
  • tests/test_workout_targets.py
 __________________________________________________
< Turning your WTFs per minute into OMGs per hour. >
 --------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The running sample now sets a pace target on its intervals and the
cycling sample a power target with a cadence secondary target, so the
demo's upload options exercise the targeted workout helpers.
@cyberjunky
cyberjunky merged commit 523491b into master Sep 29, 2026
4 of 5 checks passed
@cyberjunky
cyberjunky deleted the fix/targeted-workout-cleanup branch September 29, 2026 06:49
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.

1 participant