- Add rules_engine.py with quantitative rules for all 8 workout types - Add quality gate retry loop in generate_single_workout() - Expand calibrate_structure_rules to all 120 combinations (8 types × 5 goals × 3 sections) - Wire WeeklySplitPattern DB records into _pick_weekly_split() - Enforce movement patterns from WorkoutStructureRule in exercise selection - Add straight-set strength support (single main lift, 4-6 rounds) - Add modality consistency check for duration-dominant workout types - Add InjuryStep component to onboarding and preferences - Add sibling exercise exclusion in regenerate and preview_day endpoints - Display generator warnings on dashboard - Expand fix_rep_durations, fix_exercise_flags, fix_movement_pattern_typo - Add audit_exercise_data and check_rules_drift management commands - Add Next.js frontend with dashboard, onboarding, preferences, history pages - Add generator app with ML-powered workout generation pipeline - 96 new tests across 7 test modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
100 lines
3.6 KiB
Python
100 lines
3.6 KiB
Python
from django.db import models
|
|
from django.conf import settings
|
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
|
from random import randrange
|
|
|
|
|
|
DIFFICULTY_CHOICES = [
|
|
('beginner', 'Beginner'),
|
|
('intermediate', 'Intermediate'),
|
|
('advanced', 'Advanced'),
|
|
]
|
|
|
|
TIER_CHOICES = [
|
|
('primary', 'Primary'),
|
|
('secondary', 'Secondary'),
|
|
('accessory', 'Accessory'),
|
|
]
|
|
|
|
IMPACT_CHOICES = [
|
|
('none', 'None'),
|
|
('low', 'Low'),
|
|
('medium', 'Medium'),
|
|
('high', 'High'),
|
|
]
|
|
|
|
STRETCH_POSITION_CHOICES = [
|
|
('lengthened', 'Lengthened'),
|
|
('mid', 'Mid-range'),
|
|
('shortened', 'Shortened'),
|
|
]
|
|
|
|
|
|
# Create your models here.
|
|
class Exercise(models.Model):
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
name = models.CharField(max_length=512, default='')
|
|
description = models.CharField(null=True, blank=True, max_length=1024)
|
|
side = models.CharField(null=True, blank=True, max_length=64)
|
|
is_two_dumbbells = models.BooleanField(default=False)
|
|
is_trackable_distance = models.BooleanField(default=False)
|
|
is_alternating = models.BooleanField(default=False)
|
|
is_weight = models.BooleanField(default=False)
|
|
is_distance = models.BooleanField(default=False)
|
|
is_duration = models.BooleanField(default=False)
|
|
is_reps = models.BooleanField(default=False)
|
|
joints_used = models.CharField(null=True, blank=True, max_length=255)
|
|
movement_patterns = models.CharField(null=True, blank=True, max_length=255)
|
|
equipment_required = models.CharField(null=True, blank=True, max_length=255)
|
|
muscle_groups = models.CharField(null=True, blank=True, max_length=255)
|
|
synonyms = models.CharField(null=True, blank=True, max_length=255)
|
|
estimated_rep_duration = models.FloatField(null=True, blank=True, max_length=255)
|
|
video_override = models.CharField(null=True, blank=True, max_length=255)
|
|
|
|
# New fields for workout generation quality
|
|
is_compound = models.BooleanField(default=False)
|
|
difficulty_level = models.CharField(
|
|
max_length=16, choices=DIFFICULTY_CHOICES, null=True, blank=True
|
|
)
|
|
exercise_tier = models.CharField(
|
|
max_length=16, choices=TIER_CHOICES, null=True, blank=True
|
|
)
|
|
complexity_rating = models.IntegerField(
|
|
null=True, blank=True,
|
|
validators=[MinValueValidator(1), MaxValueValidator(5)]
|
|
)
|
|
hr_elevation_rating = models.IntegerField(
|
|
null=True, blank=True,
|
|
validators=[MinValueValidator(1), MaxValueValidator(10)]
|
|
)
|
|
impact_level = models.CharField(
|
|
max_length=8, choices=IMPACT_CHOICES, null=True, blank=True
|
|
)
|
|
stretch_position = models.CharField(
|
|
max_length=16, choices=STRETCH_POSITION_CHOICES, null=True, blank=True
|
|
)
|
|
progression_of = models.ForeignKey(
|
|
'self', null=True, blank=True, on_delete=models.SET_NULL,
|
|
related_name='progressions'
|
|
)
|
|
|
|
class Meta:
|
|
ordering = ('name',)
|
|
|
|
def __str__(self):
|
|
return (self.name or 'Unnamed') + " --------- " + (self.description or "NA")
|
|
|
|
def video_url(self):
|
|
if self.video_override is not None and len(self.video_override) > 0:
|
|
return '/media/videos/'+ self.video_override +'_720p.m3u8'
|
|
else:
|
|
name = (self.name or '').replace(" ", "_")
|
|
name = name.replace("'", "")
|
|
return '/media/hls/'+ name + ".mp4" +'_720p.m3u8'
|
|
|
|
def audio_url(self):
|
|
return "/media/exercise_audio/" + (self.name or '').replace(" ", "_") + ".m4a"
|
|
|
|
def transition_url(self):
|
|
return "/media/transitions_audio/" + self.name.replace(" ", "_") + ".m4a" |