Granular Gains: Tracking Per-Set Progress in GymFlow

The gymflow project is focused on fitness tracking. This update, part of a feature branch chain, introduces a significant enhancement to how users log their workouts and track progress: enabling per-set workout logging and a new daily progress view.

The Challenge

Before this update, users might have logged overall exercise results, like "Bench Press: 3 sets of 5 reps @ 100kg". While useful, this aggregated view didn't capture the nuance of performance across individual sets. Did the first set feel easier? Did the last set push limits? To truly understand their progress, users needed a more granular way to record their performance on a set-by-set basis, along with an intuitive way to compare these individual set performances over time.

Implementing Granularity

The core of this feature involved updating the Rutina.tsx component, where users input their workout data. Instead of a single input field per exercise, we now present per-set input groups. This allows users to meticulously log the reps, weight, or duration for each individual set of an exercise.

Upon submission, instead of a single workout entry for an exercise, multiple workout_logs are inserted into the database – one for each recorded set. This change in data model allows for richer analysis.

Crucially, the system also implements per-set baseline detection. When a user logs a set, the application automatically compares their current performance for that specific (exercise_id, set_number) combination against their historical best for that exact set. This immediate feedback helps users see if they're improving, maintaining, or struggling.

Here's a simplified look at how the data might be structured for insertion (conceptually):

// Example of data being prepared for multiple log inserts
interface SetLog {
  exerciseId: string;
  setNumber: number;
  weight: number;
  reps: number;
  date: string;
}

const workoutData = [
  { exerciseId: "bench_press", setNumber: 1, weight: 100, reps: 5, date: "2023-10-27" },
  { exerciseId: "bench_press", setNumber: 2, weight: 100, reps: 4, date: "2023-10-27" },
  { exerciseId: "bench_press", setNumber: 3, weight: 95, reps: 5, date: "2023-10-27" },
  // ... other sets
];

// This array would then be mapped to individual Supabase insert operations.

And for baseline detection, a SQL query might look something like this to fetch the previous best for a specific set:

-- Conceptual SQL query for baseline detection
SELECT
    MAX(weight) AS best_weight,
    MAX(reps) AS best_reps
FROM
    workout_logs
WHERE
    exercise_id = 'bench_press' AND set_number = 1;

Visualizing Progress

With granular data now being captured, the next step was to provide a powerful way to visualize this progress. The Progreso.tsx component was enhanced with a new "Por dia" (By Day) tab. This tab includes a day selector, allowing users to pick a specific date and review their workout performance from that day.

Within this view, users can see per-set comparisons, showing their performance for each set on the selected day against their established baseline. A clear delta (e.g., +5kg, -1 rep) immediately highlights changes, making it easy to track incremental improvements or identify areas needing attention.

Ensuring Compatibility

A critical aspect of this update was ensuring backward compatibility. Exercises without existing sets_data (legacy data) seamlessly revert to the single-field UI, preventing any disruption for users with older workout logs. The system also gracefully handles no-data states, displaying a "-" where information isn't available, and integrates smoothly with existing legacy data structures without requiring migrations or data loss.

The Outcome

By enabling per-set workout logging and providing a detailed daily progress view, the gymflow application now offers a significantly richer and more insightful experience for users. They can pinpoint exactly where they are making gains or facing plateaus, leading to more informed training decisions. This granular approach transforms raw workout data into actionable insights, empowering users to optimize their fitness journey more effectively.

When enhancing data tracking, consider the level of granularity required for true insight. Implementing fine-grained logging, even if it means adjusting data models and UI, can unlock powerful analytical capabilities that empower users with actionable intelligence. Always plan for backward compatibility to ensure a smooth transition for existing users and data.


Generated with Gitvlg.com

Granular Gains: Tracking Per-Set Progress in GymFlow
K

KamelotDeveloper

Author

Share: