hevy-shared 1.0.563 → 1.0.564

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.
package/built/index.d.ts CHANGED
@@ -465,8 +465,10 @@ export interface UserPreferences {
465
465
  live_pr_volume?: LivePRVolumeOption;
466
466
  inline_set_timer_enabled?: boolean;
467
467
  default_workout_visibility_public?: boolean;
468
+ /** Only updateable by the backend within a special API */
469
+ volume_includes_warmup_sets?: boolean;
468
470
  }
469
- export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username'>;
471
+ export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username' | 'volume_includes_warmup_sets'>;
470
472
  export type FollowingStatus = 'not-following' | 'following' | 'requested';
471
473
  export type FollowingStatusMap = {
472
474
  [id: string]: Omit<FollowingStatus, 'not-following'>;
@@ -778,6 +780,11 @@ export interface Workout {
778
780
  * why we added estimated_volume_kg
779
781
  */
780
782
  estimated_volume_kg: number;
783
+ /**
784
+ * Whether to include warmup sets in various calculations.
785
+ * https://github.com/hevyapp/hevy-shared/pull/312
786
+ */
787
+ include_warmup_sets: boolean;
781
788
  is_private: boolean;
782
789
  /**
783
790
  * If applicable, the user ID of the coach who logged this workout
@@ -1324,6 +1331,18 @@ export interface WarmupCalculatorData {
1324
1331
  dumbbellRoundingSettingLbs: number;
1325
1332
  warmupSets: WarmupSet[];
1326
1333
  }
1334
+ export interface RecalculateSetPRProgress {
1335
+ numWorkoutsProcessed: number;
1336
+ numWorkoutsTotal: number;
1337
+ }
1338
+ export type RecalculateSetPRStatusResponse = {
1339
+ type: 'ready';
1340
+ } | {
1341
+ type: 'busy';
1342
+ progress: RecalculateSetPRProgress;
1343
+ } | {
1344
+ type: 'error';
1345
+ };
1327
1346
  export interface ExerciseTemplateUnit {
1328
1347
  id: number;
1329
1348
  exercise_template_id: string;
@@ -4,7 +4,10 @@ const workoutVolume_1 = require("../workoutVolume");
4
4
  describe('workoutVolume', () => {
5
5
  describe('estimatedWorkoutVolumeKg', () => {
6
6
  it('calculates the correct workout volume', () => {
7
- const emptyWorkout = { exercises: [] };
7
+ const emptyWorkout = {
8
+ exercises: [],
9
+ include_warmup_sets: true,
10
+ };
8
11
  const weightRepsWorkout = {
9
12
  exercises: [
10
13
  {
@@ -14,6 +17,7 @@ describe('workoutVolume', () => {
14
17
  hundred_percent_bodyweight_exercise: false,
15
18
  sets: [
16
19
  {
20
+ indicator: 'normal',
17
21
  weight_kg: 100,
18
22
  reps: 10,
19
23
  distance_meters: 0,
@@ -21,6 +25,7 @@ describe('workoutVolume', () => {
21
25
  ],
22
26
  },
23
27
  ],
28
+ include_warmup_sets: true,
24
29
  };
25
30
  const pullUpWorkout = {
26
31
  exercises: [
@@ -31,6 +36,7 @@ describe('workoutVolume', () => {
31
36
  hundred_percent_bodyweight_exercise: true,
32
37
  sets: [
33
38
  {
39
+ indicator: 'normal',
34
40
  weight_kg: 0,
35
41
  reps: 10,
36
42
  distance_meters: 0,
@@ -38,6 +44,7 @@ describe('workoutVolume', () => {
38
44
  ],
39
45
  },
40
46
  ],
47
+ include_warmup_sets: true,
41
48
  };
42
49
  const assistedPullUpWorkout = {
43
50
  exercises: [
@@ -48,6 +55,7 @@ describe('workoutVolume', () => {
48
55
  hundred_percent_bodyweight_exercise: true,
49
56
  sets: [
50
57
  {
58
+ indicator: 'normal',
51
59
  weight_kg: 10,
52
60
  reps: 10,
53
61
  distance_meters: 0,
@@ -55,6 +63,7 @@ describe('workoutVolume', () => {
55
63
  ],
56
64
  },
57
65
  ],
66
+ include_warmup_sets: true,
58
67
  };
59
68
  const weightedPullUpWorkout = {
60
69
  exercises: [
@@ -65,6 +74,7 @@ describe('workoutVolume', () => {
65
74
  hundred_percent_bodyweight_exercise: true,
66
75
  sets: [
67
76
  {
77
+ indicator: 'normal',
68
78
  weight_kg: 10,
69
79
  reps: 10,
70
80
  distance_meters: 0,
@@ -72,6 +82,7 @@ describe('workoutVolume', () => {
72
82
  ],
73
83
  },
74
84
  ],
85
+ include_warmup_sets: true,
75
86
  };
76
87
  const shortDistanceWeightWorkout = {
77
88
  exercises: [
@@ -82,6 +93,7 @@ describe('workoutVolume', () => {
82
93
  hundred_percent_bodyweight_exercise: false,
83
94
  sets: [
84
95
  {
96
+ indicator: 'normal',
85
97
  weight_kg: 100,
86
98
  reps: 0,
87
99
  distance_meters: 10,
@@ -89,6 +101,7 @@ describe('workoutVolume', () => {
89
101
  ],
90
102
  },
91
103
  ],
104
+ include_warmup_sets: true,
92
105
  };
93
106
  expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
94
107
  bodyweightKg: 100,
@@ -124,8 +137,49 @@ describe('workoutVolume', () => {
124
137
  ...weightedPullUpWorkout.exercises,
125
138
  ...shortDistanceWeightWorkout.exercises,
126
139
  ],
140
+ include_warmup_sets: true,
127
141
  },
128
142
  })).toBe(5000);
129
143
  });
144
+ it('takes warmup sets into account only if `include_warmup_sets` === `true`', () => {
145
+ const workoutWithWarmupSets = {
146
+ exercises: [
147
+ {
148
+ exercise_type: 'weight_reps',
149
+ exercise_template_id: 'asd',
150
+ volume_doubling_enabled: false,
151
+ hundred_percent_bodyweight_exercise: false,
152
+ sets: [
153
+ {
154
+ indicator: 'warmup',
155
+ weight_kg: 100,
156
+ reps: 10,
157
+ distance_meters: 0,
158
+ },
159
+ {
160
+ indicator: 'normal',
161
+ weight_kg: 100,
162
+ reps: 10,
163
+ distance_meters: 0,
164
+ },
165
+ {
166
+ indicator: 'normal',
167
+ weight_kg: 100,
168
+ reps: 10,
169
+ distance_meters: 0,
170
+ },
171
+ ],
172
+ },
173
+ ],
174
+ };
175
+ expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
176
+ bodyweightKg: 100,
177
+ workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: false }),
178
+ })).toBe(2000);
179
+ expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
180
+ bodyweightKg: 100,
181
+ workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: true }),
182
+ })).toBe(3000);
183
+ });
130
184
  });
131
185
  });
@@ -1,4 +1,4 @@
1
- import { BodyMeasurement, ExerciseType, BaseExerciseTemplate } from '.';
1
+ import { BodyMeasurement, ExerciseType, BaseExerciseTemplate, WorkoutExerciseSet } from '.';
2
2
  export declare const isVolumeDoublingSupportableForExerciseTemplate: (exerciseTemplate: Pick<BaseExerciseTemplate, "equipment_category" | "exercise_type">) => boolean;
3
3
  export interface VolumeCalculableWorkout {
4
4
  exercises: {
@@ -6,13 +6,9 @@ export interface VolumeCalculableWorkout {
6
6
  exercise_template_id: string;
7
7
  volume_doubling_enabled: boolean;
8
8
  hundred_percent_bodyweight_exercise: boolean;
9
- sets: {
10
- weight_kg?: number | null;
11
- reps?: number | null;
12
- distance_meters?: number | null;
13
- duration_seconds?: number | null;
14
- }[];
9
+ sets: Pick<WorkoutExerciseSet, 'indicator' | 'weight_kg' | 'reps' | 'distance_meters' | 'duration_seconds'>[];
15
10
  }[];
11
+ include_warmup_sets: boolean;
16
12
  }
17
13
  export interface TimestampedVolumeCalculableWorkout extends VolumeCalculableWorkout {
18
14
  start_time: number;
@@ -98,7 +98,9 @@ const setVolumeKg = (set, bodyweightKg) => {
98
98
  exports.setVolumeKg = setVolumeKg;
99
99
  const workoutToWorkoutVolumeSets = (workout) => {
100
100
  const unflatSets = workout.exercises.map((e) => {
101
- return e.sets.map((s) => {
101
+ return e.sets
102
+ .filter((s) => workout.include_warmup_sets || s.indicator !== 'warmup')
103
+ .map((s) => {
102
104
  var _a, _b, _c;
103
105
  return {
104
106
  type: e.exercise_type || 'weight_reps',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.563",
3
+ "version": "1.0.564",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",