hevy-shared 1.0.727 → 1.0.728

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,12 +61,26 @@ const getTrainerRestTimerSeconds = (preset, goal, exerciseCategory) => {
61
61
  return preset.settings.rest_timers[goal][exerciseCategory];
62
62
  };
63
63
  exports.getTrainerRestTimerSeconds = getTrainerRestTimerSeconds;
64
- // Utility functions for better code organization
64
+ /**
65
+ * Checks if an exercise is compatible with the user's equipments
66
+ *
67
+ * - We enable plate exercises where users have barbell as an equipment
68
+ * - None and other equipment categories are also always allowed
69
+ * - Otherwise, the exercise is only allowed if the user has that equipment
70
+ */
65
71
  const isEquipmentCompatible = (exercise, allowedEquipments) => {
66
72
  return (allowedEquipments.includes(exercise.equipment_category) ||
67
73
  exercise.equipment_category === 'none' ||
68
- exercise.equipment_category === 'other');
74
+ exercise.equipment_category === 'other' ||
75
+ (exercise.equipment_category === 'plate' &&
76
+ allowedEquipments.includes('barbell')));
69
77
  };
78
+ /**
79
+ * Checks if a barbell limit is exceeded
80
+ *
81
+ * - We allow up to 2 barbell exercises per routine
82
+ * - Unless the user ONLY has barbell as an allowed equipment
83
+ */
70
84
  const isBarbellLimitExceeded = (exercise, routineBarbellExerciseCount, allowedEquipments) => {
71
85
  return (exercise.equipment_category === 'barbell' &&
72
86
  routineBarbellExerciseCount >= MAX_BARBELL_EXERCISES_PER_ROUTINE &&
@@ -80,7 +94,7 @@ const isExerciseUsed = (exercise, context) => {
80
94
  false);
81
95
  };
82
96
  const isolationExerciseAlternatives = {
83
- chest: ['B74A95BB', '392887AA', '39C99849'],
97
+ chest: ['B74A95BB', '392887AA', '39C99849', '982734D4'],
84
98
  triceps: ['6575F52D', 'CD6DC8E5'],
85
99
  quadriceps: ['32HKJ34K', 'A733CC5B', '9694DA61'],
86
100
  hamstrings: ['F6948F17', '487B3755', 'CDA23948'],
@@ -220,10 +234,9 @@ const pickExerciseForPrescription = (params) => {
220
234
  exercise = findAlternativeIsolationExercise(exercises, criteria, routineContext);
221
235
  if (exercise)
222
236
  return exercise;
223
- // Pass 5: Find compound exercise that uses the same muscle group as the isolation exercise
224
- if (criteria.exerciseCategory === 'isolation') {
225
- exercise = findMatchingExercise(exercises, Object.assign(Object.assign({}, criteria), { exerciseCategory: 'compound' }), routineContext);
226
- }
237
+ // Pass 5: Find exercise regardless of exercise category (isolation or compound)
238
+ // So search for compound if the exercise category is isolation, and vice versa
239
+ exercise = findMatchingExercise(exercises, Object.assign(Object.assign({}, criteria), { exerciseCategory: criteria.exerciseCategory === 'isolation' ? 'compound' : 'isolation' }), routineContext);
227
240
  return exercise;
228
241
  };
229
242
  exports.pickExerciseForPrescription = pickExerciseForPrescription;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.727",
3
+ "version": "1.0.728",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",