feat: add smart "Workout Now" recommendation to workout picker

Auto-recommends the next workout in the 4-day cycle based on the
user's last completed session (one with logged sets). Redesigns
the /workouts page with highlighted recommendation card and
renames the back button to "Change Workout".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 13:05:39 -05:00
parent 931e452205
commit 4b117c6fa7
4 changed files with 60 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ from typing import Optional
import structlog
from sqlmodel import Session, select
from app.models.workout_log import WorkoutLog
from app.models.workout_session import WorkoutSession
logger = structlog.get_logger(__name__)
@@ -71,6 +72,17 @@ class WorkoutSessionService:
)
return ws
def get_last_completed_session(self, user_id: int) -> Optional[WorkoutSession]:
"""Get the most recent session that has at least one logged set."""
statement = (
select(WorkoutSession)
.join(WorkoutLog, WorkoutLog.session_id == WorkoutSession.id)
.where(WorkoutSession.user_id == user_id)
.order_by(WorkoutSession.date.desc())
.limit(1)
)
return self._session.exec(statement).first()
def list_sessions(
self,
user_id: int,