feat: replace wk1/wk4 targets with 6→8→10→12 rep ladder progression
Simplifies the progression model to a universal rep ladder: every exercise follows 6→8→10→12 reps at current weight, then +5 lbs and reset to 6. Replaces per-user wk1/wk4 rep and weight targets with a single starting_weight field. - Add Alembic migration to drop wk1_reps/wk4_reps/wk1_weight/wk4_weight, add starting_weight (migrated from wk1_weight) - Run Alembic migrations on app startup instead of create_all, with auto-detection and stamping for legacy databases - Include alembic/ and alembic.ini in Docker image - Rewrite progression_service.get_suggestion() with ladder logic: climb, hold, weight_increase, hold_at_top, deload - Replace wk1/wk4 grid in exercise cards with rep ladder progress bar - Add color-coded progression badges by type - Change weight log input from text to number with pre-filled suggestion - Normalize weight input in routes (0→BW, bare number→N lbs) - Remove schedule page (route, template, nav link, tests) - Simplify user_programs.yaml from 4 fields to 1 per exercise - Update all tests for new schema and progression logic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,23 @@ logger = structlog.get_logger(__name__)
|
||||
router = APIRouter(prefix="/log", tags=["logging"])
|
||||
|
||||
|
||||
def _normalize_weight(raw: str) -> str:
|
||||
"""Convert numeric weight input to display format.
|
||||
|
||||
'0' or '' → 'BW', bare number → '{n} lbs', already formatted → pass through.
|
||||
"""
|
||||
raw = raw.strip()
|
||||
if not raw or raw == "0":
|
||||
return "BW"
|
||||
try:
|
||||
num = float(raw)
|
||||
if num == int(num):
|
||||
return f"{int(num)} lbs"
|
||||
return f"{num} lbs"
|
||||
except ValueError:
|
||||
return raw
|
||||
|
||||
|
||||
@router.post("", response_class=HTMLResponse)
|
||||
async def log_set(
|
||||
request: Request,
|
||||
@@ -38,7 +55,7 @@ async def log_set(
|
||||
workout_day_id = int(form.get("workout_day_id", 0))
|
||||
set_number = int(form.get("set_number", 1))
|
||||
reps = int(form.get("reps", 0))
|
||||
weight = form.get("weight", "")
|
||||
weight = _normalize_weight(form.get("weight", ""))
|
||||
felt_easy = form.get("felt_easy") == "on"
|
||||
|
||||
# Get or create today's session
|
||||
@@ -89,7 +106,7 @@ async def edit_log(
|
||||
log_service.update_log(
|
||||
log_id,
|
||||
reps_completed=int(form.get("reps", 0)),
|
||||
weight_used=form.get("weight", ""),
|
||||
weight_used=_normalize_weight(form.get("weight", "")),
|
||||
felt_easy=form.get("felt_easy") == "on",
|
||||
notes=form.get("notes"),
|
||||
)
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
"""4-week schedule calendar routes.
|
||||
|
||||
Displays a calendar view showing which workout day maps to which date.
|
||||
"""
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
import structlog
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from sqlmodel import Session
|
||||
|
||||
from app.database import get_db_session
|
||||
from app.models.user import User
|
||||
from app.services.exercise_service import ExerciseService
|
||||
from app.services.workout_session_service import WorkoutSessionService
|
||||
from app.utils.auth import require_active_profile
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/schedule", tags=["schedule"])
|
||||
|
||||
|
||||
@router.get("", response_class=HTMLResponse)
|
||||
async def schedule_view(
|
||||
request: Request,
|
||||
session: Session = Depends(get_db_session),
|
||||
profile: User = Depends(require_active_profile),
|
||||
):
|
||||
"""Render the 4-week schedule calendar.
|
||||
|
||||
Shows a 4-week grid where each training day is mapped to a
|
||||
calendar date. Days with completed sessions are highlighted.
|
||||
"""
|
||||
exercise_service = ExerciseService(session)
|
||||
workout_days = exercise_service.list_workout_days()
|
||||
|
||||
# Build 4-week calendar starting from Monday of current week
|
||||
today = date.today()
|
||||
monday = today - timedelta(days=today.weekday())
|
||||
|
||||
weeks = []
|
||||
completed_dates = set()
|
||||
|
||||
# Get completed sessions for highlighting
|
||||
ws_service = WorkoutSessionService(session)
|
||||
sessions_list = ws_service.list_sessions(
|
||||
user_id=profile.id, limit=100,
|
||||
)
|
||||
completed_dates = {ws.date for ws in sessions_list}
|
||||
|
||||
# 4 workout days per week, 4 weeks
|
||||
for week_num in range(4):
|
||||
week_start = monday + timedelta(weeks=week_num)
|
||||
week_data = {
|
||||
"week_number": week_num + 1,
|
||||
"days": [],
|
||||
}
|
||||
for day_offset, workout_day in enumerate(workout_days):
|
||||
training_date = week_start + timedelta(days=day_offset)
|
||||
is_today = training_date == today
|
||||
is_completed = training_date in completed_dates
|
||||
|
||||
week_data["days"].append({
|
||||
"workout_day": workout_day,
|
||||
"date": training_date,
|
||||
"is_today": is_today,
|
||||
"is_completed": is_completed,
|
||||
})
|
||||
weeks.append(week_data)
|
||||
|
||||
templates = request.app.state.templates
|
||||
return templates.TemplateResponse("pages/schedule.html", {
|
||||
"request": request,
|
||||
"weeks": weeks,
|
||||
"active_profile": profile,
|
||||
})
|
||||
Reference in New Issue
Block a user