Add per-exercise personal record tracking
Session tracking only ever stored a done boolean - no record of what weight or reps were actually performed, so there was no way to derive real progress data even though the dashboard implied "progress tracking" was a thing. Workout templates only hold a static planned value, not a history of performance. Adds actual_weight/actual_reps to workout_session_items, captured inline when checking off a set in a session (defaults to the workout's planned weight/reps, editable before confirming). The exercise detail page now shows the user's personal best (heaviest completed set, tie broken by reps) computed from their completed session history across all workouts containing that exercise. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,11 @@ class WorkoutSessionController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'actual_weight' => ['nullable', 'numeric', 'min:0', 'max:9999.99'],
|
||||
'actual_reps' => ['nullable', 'integer', 'min:0', 'max:1000'],
|
||||
]);
|
||||
|
||||
$si = WorkoutSessionItem::firstOrCreate([
|
||||
'session_id' => $session->id,
|
||||
'workout_exercise_id' => $item->id,
|
||||
@@ -66,6 +71,14 @@ class WorkoutSessionController extends Controller
|
||||
]);
|
||||
|
||||
$si->done = !$si->done;
|
||||
if ($si->done) {
|
||||
if (array_key_exists('actual_weight', $data) && $data['actual_weight'] !== null) {
|
||||
$si->actual_weight = $data['actual_weight'];
|
||||
}
|
||||
if (array_key_exists('actual_reps', $data) && $data['actual_reps'] !== null) {
|
||||
$si->actual_reps = $data['actual_reps'];
|
||||
}
|
||||
}
|
||||
$si->save();
|
||||
|
||||
return back();
|
||||
|
||||
Reference in New Issue
Block a user