workout generator audit: rules engine, structure rules, split patterns, injury UX, metadata cleanup
- 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>
This commit is contained in:
@@ -1,12 +1,40 @@
|
||||
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(null=True, blank=True, max_length=512)
|
||||
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)
|
||||
@@ -24,26 +52,49 @@ class Exercise(models.Model):
|
||||
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 + " --------- " + self.description or "NA"
|
||||
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 "/videos/hls_video?video_name="+self.video_override+".mp4&video_type=exercise_videos"
|
||||
return '/media/videos/'+ self.video_override +'_720p.m3u8'
|
||||
# return "/media/exercise_videos/" + self.video_override
|
||||
else:
|
||||
#return "/videos/hls_video?video_name="+self.name.replace(" ", "_")+".mp4&video_type=exercise_videos"
|
||||
name = self.name.replace(" ", "_")
|
||||
name = (self.name or '').replace(" ", "_")
|
||||
name = name.replace("'", "")
|
||||
return '/media/hls/'+ name + ".mp4" +'_720p.m3u8'
|
||||
#return "/media/exercise_videos/" + self.name.replace(" ", "_") + ".mp4"
|
||||
|
||||
|
||||
def audio_url(self):
|
||||
return "/media/exercise_audio/" + self.name.replace(" ", "_") + ".m4a"
|
||||
return "/media/exercise_audio/" + (self.name or '').replace(" ", "_") + ".m4a"
|
||||
|
||||
def transition_url(self):
|
||||
return "/media/transitions_audio/" + self.name.replace(" ", "_") + ".m4a"
|
||||
Reference in New Issue
Block a user