garth
garth copied to clipboard
Add multi-device support for training status endpoints
Description
The current training status implementation only supports single-device scenarios. The code assumes the first device in the API response and ignores additional devices.
Current Limitation
In the _parse_response methods for training status classes, we use:
# Get the first device's data (assumes single device for now)
for device_data in report_data.values():
# Process only the first device and return
return [device_data] if isinstance(device_data, dict) else result
Proposed Enhancement
Add support for multiple devices by:
- Processing all devices in the API response instead of just the first one
- Adding device identification to the returned data structures
- Updating the data model to include device-specific information
- Maintaining backward compatibility with existing single-device usage
Implementation Ideas
- Add a
device_idfield to clearly identify which device each training status entry belongs to - Modify
_parse_responseto iterate through all devices inreportData - Consider adding a class method like
list_by_device()for device-specific queries - Update tests to cover multi-device scenarios
Files Affected
src/garth/stats/training_status/daily.pysrc/garth/stats/training_status/weekly.pysrc/garth/stats/training_status/monthly.pytests/stats/test_training_status.py
Priority
Low - Current single-device support covers most use cases, but this would be valuable for users with multiple Garmin devices.