Repository: IgnisDa/ryot (language: rust)

Issue:
Exercise charts displaying incorrect data for reps
Version: V7.2.0

I've logged 3 workouts with "overhead squat".

workout 1: Aug 5
30 kg x 4

workout 2: Jul 1
30 kg x 5

workout 3: Sep 9
30 kg x 5
30 kg x 8
30 kg x 5

Going to exercise history correctly shows the above. Going over to the charts tab however, and viewing the reps graph shows
09/09: 8
11/09: 5
11/09: 4

The rep numbers are correct, but assigned to the wrong dates, one date is missing, and one date occurs twice.

Viewing the exercise charts for many other exercises, AFAIK the graphs have the correct Y axis data, and in the correct order, but every entry shows 11/09 (today) as the date.

Possible cause, I recently started using Ryot and wanted to add historical exercise data. So I added workouts, but couldn't set the date until after logging the workout, then using "adjust time" to backdate them. The graphs seem to have locked onto the date data as soon as the workout was added, and not changed after using "adjust time".


Discussion / hints:
Try re-evaluate workouts from miscellaneous settings and lmk if the issue still persist.
This has fixed it, thanks.
Reopening this since this should ideally be handled by the application.

@talkingseedling you might also want to trigger the recalculate summary job since you drastically changed the workout times.

Fix patch:
diff --git a/crates/services/fitness/src/lib.rs b/crates/services/fitness/src/lib.rs
index 732054d208..8bce6a9477 100644
--- a/crates/services/fitness/src/lib.rs
+++ b/crates/services/fitness/src/lib.rs
@@ -450,7 +450,7 @@ impl ExerciseService {
         input: UpdateUserWorkoutInput,
     ) -> Result<bool> {
         if let Some(wkt) = Workout::find()
-            .filter(workout::Column::UserId.eq(user_id))
+            .filter(workout::Column::UserId.eq(&user_id))
             .filter(workout::Column::Id.eq(input.id))
             .one(&self.db)
             .await?
@@ -464,6 +464,10 @@ impl ExerciseService {
             }
             if new_wkt.is_changed() {
                 new_wkt.update(&self.db).await?;
+                self.perform_application_job
+                    .enqueue(ApplicationJob::ReEvaluateUserWorkouts(user_id))
+                    .await
+                    .unwrap();
                 Ok(true)
             } else {
                 Ok(false)


Test patch: