Skip to content

Comments

Validate Workout Logging and Streak Tracking#226

Open
cejiogu wants to merge 5 commits intomasterfrom
chimdi/workout-logging-testing
Open

Validate Workout Logging and Streak Tracking#226
cejiogu wants to merge 5 commits intomasterfrom
chimdi/workout-logging-testing

Conversation

@cejiogu
Copy link

@cejiogu cejiogu commented Feb 22, 2026

Overview

In this PR, I:

  • Implement bug fixes to the logWorkout mutation
  • Add a totalGymDays field to the GraphQL User type
  • Refactor implementation for tracking a user's active streak and max streak
  • Modify resolver for getWorkoutHistory to simplify querying for user workouts
  • Refactor logging of workout goals

Changes Made

Change 1: logWorkout Mutation Fixes

  • Fixed edge cases where duplicate workouts could be logged for the same user/day.
  • Improved validation logic to ensure workouts are properly associated with authenticated users.
  • Corrected streak calculation logic when logging workouts retroactively.
  • Ensured database writes are atomic to prevent partial updates in failure cases.

Change 2: totalGymDays GraphQL Field

  • Added a new computed field totalGymDays to the User type.
  • Resolver calculates the total number of distinct days on which a user logged workouts.

Change 3: Streak Logic Refactor

  • Refactored logic to:
    • Correctly compute active_streak while respecting shifts in workout goals
    • Maintain max_streak
    • Update streak start date when applicable

Change 4: getWorkoutHistory Resolver Simplification

  • Transitioned implementation from Strings to list of Workouts

Change 5: Workout Goal Logging Refactor

  • Convert workout goals from specific days of the week to a number of days in a 7-day period
  • Cleaned up goal-tracking logic to ensure weekly goals are evaluated consistently

Test Coverage

Tested locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant