GideonNeedleman / 5x5

0 stars 0 forks source link

Check for conflicting set ids #132

Closed GideonNeedleman closed 9 months ago

GideonNeedleman commented 9 months ago

May get conflicting set ids if I edit a workout by deleting an exercise, then adding a new exercise.

For example, assume 2 exercises:

ex1.sets[
  id: 1,
  id: 2,
]

ex2.sets[
  id: 3,
  id: 4,
]

Then I delete exercise 1 and replace it with exercise 3. Would I get the following result?

ex3.sets[
  id: 3,
]

ex2.sets[
  id: 3,
  id: 4,
]

Since when adding ex3 the number of existing sets is 2, so I'd assign setId to be 3, but this conflicts with setId 3 in exercise 2.


Maybe just go with unique UUIDs or something for all sets. Or eliminate sets and rely on array index.

I want to be able to save modified workouts from DoWorkout and Just Go.

GideonNeedleman commented 9 months ago

I just checked and actually this problem doesn't occur. When editing a set the ids are completely regenerated upon save, so what you actually get is:

ex3.sets[
  id: 1,
]

ex2.sets[
  id: 2,
  id: 3,
]

So there's no problem. This bodes well for saving Just Go or modified workouts bc there won't be any id conflict. And then if this workout is later edited, the ids will all be regenerated anyway.