Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correctly migrate the number of sets

Roland Geider1077651e88a4
diff --git a/wger/manager/migrations/0019_flexible_routines_migration.py b/wger/manager/migrations/0019_flexible_routines_migration.py
index e411d8d0d..5ad761f54 100644
--- a/wger/manager/migrations/0019_flexible_routines_migration.py
+++ b/wger/manager/migrations/0019_flexible_routines_migration.py
@@ -75,7 +75,11 @@ def migrate_routines(apps) -> dict[int, Any]:
for set_obj in day.set_set.all():
slot = Slot(day=current_day, comment=set_obj.comment, order=set_obj.order)
slot.save()
+ one_setting = set_obj.setting_set.count() == 1
+
for setting in set_obj.setting_set.all():
+ nr_sets = set_obj.sets if one_setting else 1
+
slot_entry = SlotEntry(
slot=slot,
exercise=setting.exercise_base,
@@ -129,7 +133,7 @@ def migrate_routines(apps) -> dict[int, Any]:
SetsConfig(
slot_entry=slot_entry,
- value=set_obj.sets,
+ value=nr_sets,
iteration=1,
operation=REPLACE_OP,
step=ABS_STEP,