Tighten warmup selection to dynamic prep only
This commit is contained in:
@@ -117,8 +117,8 @@ class ExerciseSelector:
|
||||
|
||||
# Movement patterns considered appropriate for warm-up / cool-down
|
||||
WARMUP_PATTERNS = [
|
||||
'dynamic stretch', 'activation', 'mobility', 'warm up',
|
||||
'warmup', 'stretch', 'foam roll',
|
||||
'dynamic stretch', 'mobility - dynamic', 'activation', 'warm up',
|
||||
'warmup', 'cardio/locomotion', 'balance',
|
||||
]
|
||||
COOLDOWN_PATTERNS = [
|
||||
'static stretch', 'stretch', 'cool down', 'cooldown',
|
||||
@@ -129,6 +129,10 @@ class ExerciseSelector:
|
||||
COOLDOWN_EXCLUDED_PATTERNS = [
|
||||
'plyometric', 'combat', 'cardio/locomotion', 'olympic',
|
||||
]
|
||||
# Warm-up must avoid working-set patterns.
|
||||
WARMUP_EXCLUDED_PATTERNS = [
|
||||
'upper push', 'upper pull', 'olympic', 'combat', 'arms',
|
||||
]
|
||||
|
||||
def __init__(self, user_preference, recently_used_ids=None, hard_exclude_ids=None):
|
||||
self.user_preference = user_preference
|
||||
@@ -335,23 +339,27 @@ class ExerciseSelector:
|
||||
for kw in self.WARMUP_PATTERNS:
|
||||
warmup_q |= Q(movement_patterns__icontains=kw)
|
||||
|
||||
# Warm-up should be dynamic movement prep, not loaded working sets.
|
||||
qs = qs.exclude(is_weight=True)
|
||||
# Exclude heavy compounds (no barbell squats in warmup)
|
||||
qs = qs.exclude(is_weight=True, is_compound=True)
|
||||
qs = qs.exclude(is_compound=True)
|
||||
# Exclude primary-tier exercises (no primary lifts in warmup)
|
||||
qs = qs.exclude(exercise_tier='primary')
|
||||
# Exclude technically complex movements
|
||||
qs = qs.exclude(complexity_rating__gte=4)
|
||||
# Exclude common working-set movement families from warmup.
|
||||
warmup_exclude_q = Q()
|
||||
for pat in self.WARMUP_EXCLUDED_PATTERNS:
|
||||
warmup_exclude_q |= Q(movement_patterns__icontains=pat)
|
||||
qs = qs.exclude(warmup_exclude_q)
|
||||
|
||||
# Tightened HR filter for warmup (1-4 instead of 2-5)
|
||||
hr_warmup_q = Q(hr_elevation_rating__gte=1, hr_elevation_rating__lte=4)
|
||||
preferred = qs.filter(warmup_q).filter(
|
||||
hr_warmup_q | Q(hr_elevation_rating__isnull=True)
|
||||
)
|
||||
other = qs.exclude(pk__in=preferred.values_list('pk', flat=True)).filter(
|
||||
hr_warmup_q | Q(hr_elevation_rating__isnull=True)
|
||||
)
|
||||
|
||||
selected = self._weighted_pick(preferred, other, count)
|
||||
# STRICT: warmup must come from warmup-pattern exercises only.
|
||||
selected = self._weighted_pick(preferred, preferred.none(), count)
|
||||
|
||||
# Fallback: if not enough duration-based warmup exercises, widen to
|
||||
# any duration exercise regardless of muscle group
|
||||
@@ -362,17 +370,16 @@ class ExerciseSelector:
|
||||
fitness_level=fitness_level,
|
||||
).exclude(pk__in={e.pk for e in selected})
|
||||
# Apply same warmup safety exclusions
|
||||
wide_qs = wide_qs.exclude(is_weight=True, is_compound=True)
|
||||
wide_qs = wide_qs.exclude(is_weight=True)
|
||||
wide_qs = wide_qs.exclude(is_compound=True)
|
||||
wide_qs = wide_qs.exclude(exercise_tier='primary')
|
||||
wide_qs = wide_qs.exclude(complexity_rating__gte=4)
|
||||
wide_qs = wide_qs.exclude(warmup_exclude_q)
|
||||
wide_preferred = wide_qs.filter(warmup_q).filter(
|
||||
hr_warmup_q | Q(hr_elevation_rating__isnull=True)
|
||||
)
|
||||
wide_other = wide_qs.exclude(pk__in=wide_preferred.values_list('pk', flat=True)).filter(
|
||||
hr_warmup_q | Q(hr_elevation_rating__isnull=True)
|
||||
)
|
||||
selected.extend(
|
||||
self._weighted_pick(wide_preferred, wide_other, count - len(selected))
|
||||
self._weighted_pick(wide_preferred, wide_preferred.none(), count - len(selected))
|
||||
)
|
||||
|
||||
for ex in selected:
|
||||
|
||||
Reference in New Issue
Block a user