Back to Roadmap

Training Zones & Zone Analysis Schema

Add the training zones tables from SYNTHESIS §7. Split from #20 (HR Zone Configuration) — the schema is significantly richer than that issue describes.

Tables

training_zones

  • Zone definitions for HR, power, and pace (not just HR)
  • Versioned with effective_from dates (GoldenCheetah pattern) — insert new rows, don't overwrite old ones. Historical activities resolve to zones active at the time.
  • Both absolute and percentage-based: absolute values for coach-set or provider-synced zones, percentages for standard systems (Coggan, Karvonen, Friel)
  • Per-sport overrides: sport_type = NULL = default, sport_type = 'cycling' = cycling-specific override
  • TRIMP weighting on HR zones for HR-based training load calculation
  • UNIQUE(athlete_id, zone_type, sport_type, zone_number, effective_from)

sport_zone_priorities

  • Per-sport configuration: which metric drives time-in-zone and training load
  • load_order and tiz_order (e.g., 'POWER_HR_PACE' for cycling)
  • default_equipment_id for auto-assigning gear per sport

Zone resolution at query time

  1. Look up (athlete_id, zone_type, sport_type, effective_from <= activity.start_date) ORDER BY effective_from DESC LIMIT 1
  2. If percentage-based: resolve using nearest athlete_metrics anchor value (FTP, max HR, etc.)
  3. If absolute: use directly
  4. If no sport-specific zones: fall back to sport_type = NULL (default)

Depends on

Schema Migration

Blocks

#20, #21, #24, #25

Reference

See docs/api-research/SYNTHESIS.md §7 (training_zones table, sport_zone_priorities table).

Status
Backlog
Priority
Normal
Platform
API
Date
1 month ago