Skip to content

Commit

Permalink
Consistently use "repetitions" instead of "reps"
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Feb 1, 2025
1 parent e2acd8f commit 54a919c
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 82 deletions.
10 changes: 5 additions & 5 deletions wger/manager/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class SlotEntryStructureSerializer(serializers.ModelSerializer):
max_weight_configs = WeightConfigSerializer(source='maxweightconfig_set', many=True)
repetitions_configs = RepetitionsConfigSerializer(source='repetitionsconfig_set', many=True)
max_repetitions_configs = RepetitionsConfigSerializer(
source='maxrepetitionssconfig_set',
source='maxrepetitionsconfig_set',
many=True
)
set_nr_configs = SetNrConfigSerializer(source='setsconfig_set', many=True)
Expand Down Expand Up @@ -353,10 +353,10 @@ class SetConfigDataSerializer(serializers.Serializer):
max_weight = serializers.DecimalField(max_digits=5, decimal_places=2)
weight_unit = serializers.IntegerField()
weight_rounding = serializers.DecimalField(max_digits=4, decimal_places=2)
reps = serializers.DecimalField(max_digits=5, decimal_places=2)
max_reps = serializers.DecimalField(max_digits=5, decimal_places=2)
reps_unit = serializers.IntegerField()
reps_rounding = serializers.DecimalField(max_digits=4, decimal_places=2)
repetitions = serializers.DecimalField(max_digits=5, decimal_places=2)
max_repetitions = serializers.DecimalField(max_digits=5, decimal_places=2)
repetitions_unit = serializers.IntegerField()
repetitions_rounding = serializers.DecimalField(max_digits=4, decimal_places=2)
rir = serializers.DecimalField(max_digits=5, decimal_places=2)
max_rir = serializers.DecimalField(max_digits=5, decimal_places=2)
rpe = serializers.DecimalField(max_digits=5, decimal_places=2)
Expand Down
4 changes: 2 additions & 2 deletions wger/manager/config_calculations/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def calculate(self):
exercise=1,
sets=2,
weight=24,
reps=1,
repetitions=1,
rir=2,
rest=120,
)
Expand All @@ -35,7 +35,7 @@ def calculate(self):
exercise=2,
sets=4,
weight=42,
reps=10,
repetitions=10,
rir=1,
rest=90,
)
2 changes: 1 addition & 1 deletion wger/manager/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
('4', 4),
]

ID_UNIT_REPS = 1
ID_UNIT_REPETITIONS = 1
ID_UNIT_KG = 1
ID_UNIT_LB = 2
23 changes: 12 additions & 11 deletions wger/manager/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ class SetConfigData:
exercise: int

weight: Decimal | int | None
reps: Decimal | int | None
repetitions: Decimal | int | None
rir: Decimal | int | None
rest: int | None

max_rir: Decimal | int | None = None
max_weight: Decimal | int | None = None
max_reps: Decimal | int | None = None
max_repetitions: Decimal | int | None = None
max_rest: int | None = None
max_sets: int | None = None

sets: int = 1
weight_unit: int | None = 1
reps_unit: int | None = 1
repetitions_unit: int | None = 1
weight_rounding: Decimal | int | None = None
reps_rounding: Decimal | int | None = None
repetitions_rounding: Decimal | int | None = None

comment: str = ''
type: str = 'normal'
Expand Down Expand Up @@ -96,23 +96,24 @@ def text_repr(self) -> str:

out.append(f'{sets} {_("Sets")},')

if self.reps:
reps = round_value(self.reps, self.reps_rounding)
if self.repetitions:
reps = round_value(self.repetitions, self.repetitions_rounding)
max_reps = (
round_value(self.max_reps, self.reps_rounding) if self.max_reps else self.max_reps
round_value(self.max_repetitions,
self.repetitions_rounding) if self.max_repetitions else self.max_repetitions
)

if max_reps:
reps = f'{reps}-{max_reps}'

unit = ''
if self.reps_unit in (1, 2) and not self.weight:
if self.repetitions_unit in (1, 2) and not self.weight:
unit = _('Reps')
elif self.reps_unit == 2:
elif self.repetitions_unit == 2:
unit = '∞'
reps = ''
elif self.reps_unit not in (1, 2):
unit = _(RepetitionUnit.objects.get(pk=self.reps_unit).name)
elif self.repetitions_unit not in (1, 2):
unit = _(RepetitionUnit.objects.get(pk=self.repetitions_unit).name)

out.append(f'{reps} {unit}'.strip())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def handle(self, **options):
for exercise_id in slot_data.exercises:
for set_data in slot_data.sets:
reps = (
set_data.reps + random.randint(-1, 2)
if set_data.reps
set_data.repetitions + random.randint(-1, 2)
if set_data.repetitions
else random.randint(3, 12)
)
weight = (
Expand Down Expand Up @@ -124,8 +124,8 @@ def handle(self, **options):
exercise_id=exercise_id,
routine=routine,
repetitions=reps,
repetitions_target=set_data.reps,
repetitions_unit_id=set_data.reps_unit,
repetitions_target=set_data.repetitions,
repetitions_unit_id=set_data.repetitions_unit,
weight=weight,
weight_target=set_data.weight,
weight_unit_id=set_data.weight_unit,
Expand Down
4 changes: 2 additions & 2 deletions wger/manager/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from wger.manager.consts import (
ID_UNIT_KG,
ID_UNIT_LB,
ID_UNIT_REPS,
ID_UNIT_REPETITIONS,
)


Expand All @@ -36,7 +36,7 @@ def lb(self):

def reps(self):
"""Return all entries with reps as unit"""
return self.filter(repetitions_unit_id=ID_UNIT_REPS)
return self.filter(repetitions_unit_id=ID_UNIT_REPETITIONS)


class WorkoutLogManager(models.Manager):
Expand Down
8 changes: 4 additions & 4 deletions wger/manager/models/slot_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ def get_config(self, iteration: int) -> SetConfigData:
# TODO: decide on whether to return None or always the unit
# weight_unit=self.weight_unit.pk if weight is not None else None,
weight_unit=self.weight_unit.pk,
reps=round_value(reps, self.repetition_rounding),
max_reps=round_value(max_reps, self.repetition_rounding)
repetitions=round_value(reps, self.repetition_rounding),
max_repetitions=round_value(max_reps, self.repetition_rounding)
if max_reps and reps and max_reps > reps
else None,
reps_rounding=self.repetition_rounding if reps is not None else None,
reps_unit=self.repetition_unit.pk,
repetitions_rounding=self.repetition_rounding if reps is not None else None,
repetitions_unit=self.repetition_unit.pk,
# TODO: decide on whether to return None or always the unit
# reps_unit=self.repetition_unit.pk if reps is not None else None,
rir=self.calculate_rir(iteration),
Expand Down
24 changes: 12 additions & 12 deletions wger/manager/tests/test_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_slots_gym_mode(self):
exercise=1,
weight=80,
weight_rounding=Decimal('1.25'),
reps=4,
reps_rounding=Decimal('1.00'),
repetitions=4,
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=1,
Expand All @@ -56,8 +56,8 @@ def test_slots_gym_mode(self):
exercise=2,
weight=20,
weight_rounding=Decimal('1.25'),
reps=5,
reps_rounding=Decimal('1.00'),
repetitions=5,
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=1,
Expand Down Expand Up @@ -99,8 +99,8 @@ def test_slots_display_mode(self):
exercise=1,
weight=80,
weight_rounding=Decimal('1.25'),
reps=Decimal(4),
reps_rounding=Decimal('1.00'),
repetitions=Decimal(4),
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=5,
Expand All @@ -115,8 +115,8 @@ def test_slots_display_mode(self):
exercise=2,
weight=20,
weight_rounding=Decimal('1.25'),
reps=5,
reps_rounding=Decimal('1.00'),
repetitions=5,
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=2,
Expand All @@ -136,8 +136,8 @@ def test_slots_display_mode(self):
exercise=3,
weight=80,
weight_rounding=Decimal('1.25'),
reps=6,
reps_rounding=Decimal('1.00'),
repetitions=6,
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=5,
Expand All @@ -153,8 +153,8 @@ def test_slots_display_mode(self):
exercise=3,
weight=50,
weight_rounding=Decimal('1.25'),
reps=4,
reps_rounding=Decimal('1.00'),
repetitions=4,
repetitions_rounding=Decimal('1.00'),
rir=None,
rest=None,
sets=3,
Expand Down
10 changes: 5 additions & 5 deletions wger/manager/tests/test_routine_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from wger.manager.consts import (
ID_UNIT_KG,
ID_UNIT_LB,
ID_UNIT_REPS,
ID_UNIT_REPETITIONS,
)
from wger.manager.dataclasses import LogData
from wger.manager.models import WorkoutLog
Expand Down Expand Up @@ -51,7 +51,7 @@ def setUp(self):
user_id=1,
routine=self.routine,
date=datetime.date(2024, 2, 1),
repetitions_unit_id=ID_UNIT_REPS,
repetitions_unit_id=ID_UNIT_REPETITIONS,
repetitions=5,
weight_unit_id=ID_UNIT_KG,
weight=10,
Expand All @@ -64,7 +64,7 @@ def setUp(self):
user_id=1,
routine=self.routine,
date=datetime.date(2024, 2, 2),
repetitions_unit_id=ID_UNIT_REPS,
repetitions_unit_id=ID_UNIT_REPETITIONS,
repetitions=1,
weight_unit_id=ID_UNIT_KG,
weight=10,
Expand All @@ -77,7 +77,7 @@ def setUp(self):
user_id=1,
routine=self.routine,
date=datetime.date(2024, 2, 10),
repetitions_unit_id=ID_UNIT_REPS,
repetitions_unit_id=ID_UNIT_REPETITIONS,
repetitions=1,
weight_unit_id=ID_UNIT_KG,
weight=10,
Expand All @@ -90,7 +90,7 @@ def setUp(self):
user_id=1,
routine=self.routine,
date=datetime.date(2024, 2, 10),
repetitions_unit_id=ID_UNIT_REPS,
repetitions_unit_id=ID_UNIT_REPETITIONS,
repetitions=1,
weight_unit_id=ID_UNIT_LB,
weight=10,
Expand Down
24 changes: 12 additions & 12 deletions wger/manager/tests/test_set_config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def setUp(self):
exercise=1,
type='normal',
sets=1,
reps=4,
reps_unit=1,
repetitions=4,
repetitions_unit=1,
weight=20,
weight_unit=1,
rir=3,
Expand Down Expand Up @@ -73,31 +73,31 @@ def test_text_repr_weight_rounding(self):
self.assertEqual(self.config.text_repr, '4 × 20 kg @ 3 RiR')

def test_text_repr_reps_unit(self):
self.config.reps = 90
self.config.reps_unit = 3
self.config.repetitions = 90
self.config.repetitions_unit = 3
self.assertEqual(self.config.text_repr, '90 Seconds × 20 kg @ 3 RiR')

def test_text_repr_reps_unit_no_weight(self):
self.config.reps = 90
self.config.reps_unit = 3
self.config.repetitions = 90
self.config.repetitions_unit = 3
self.config.weight = None
self.assertEqual(self.config.text_repr, '90 Seconds @ 3 RiR')

def test_text_repr_reps_rounding(self):
self.config.reps = 4.72
self.config.reps_rounding = 2.5
self.config.repetitions = 4.72
self.config.repetitions_rounding = 2.5
self.assertEqual(self.config.text_repr, '5 × 20 kg @ 3 RiR')

def test_text_repr_rir_rounding(self):
self.config.rir = 2.50
self.assertEqual(self.config.text_repr, '4 × 20 kg @ 2.5 RiR')

def test_text_repr_amrap(self):
self.config.reps_unit = 2
self.config.repetitions_unit = 2
self.assertEqual(self.config.text_repr, '∞ × 20 kg @ 3 RiR')

def test_text_repr_reps_range(self):
self.config.max_reps = 6
self.config.max_repetitions = 6
self.assertEqual(self.config.text_repr, '4-6 × 20 kg @ 3 RiR')

def test_text_repr_weight_range(self):
Expand Down Expand Up @@ -125,8 +125,8 @@ def test_text_repr_only_sets(self):
self.config.sets = 3
self.config.weight = None
self.config.max_weight = None
self.config.max_reps = None
self.config.reps = None
self.config.max_repetitions = None
self.config.repetitions = None
self.config.rir = None
self.assertEqual(self.config.text_repr, '3 Sets')

Expand Down
Loading

0 comments on commit 54a919c

Please sign in to comment.