@dgpholdings/greatoak-shared 1.1.117 → 1.1.119
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.
|
@@ -59,6 +59,21 @@ export type TApiGetTrainerClientListRes = {
|
|
|
59
59
|
export type TApiTrainerGetClientWorkoutHistoryReq = {
|
|
60
60
|
clientId: string;
|
|
61
61
|
};
|
|
62
|
+
export type TExerciseScore = {
|
|
63
|
+
exerciseId: string;
|
|
64
|
+
score: number;
|
|
65
|
+
muscleScores: {
|
|
66
|
+
[muscleGroup: string]: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type TRecentSession = {
|
|
70
|
+
createdAt: Date;
|
|
71
|
+
userDuration: number;
|
|
72
|
+
planId: string | null;
|
|
73
|
+
isOwnPlan: boolean;
|
|
74
|
+
sessionRecord?: TClientSessionData[];
|
|
75
|
+
exerciseScores?: TExerciseScore[];
|
|
76
|
+
};
|
|
62
77
|
export type TApiTrainerGetClientWorkoutHistoryRes = {
|
|
63
78
|
status: 200;
|
|
64
79
|
state: "success";
|
|
@@ -66,6 +81,7 @@ export type TApiTrainerGetClientWorkoutHistoryRes = {
|
|
|
66
81
|
fullName?: string;
|
|
67
82
|
clientEmail?: string;
|
|
68
83
|
history: Pick<TClientWorkoutHistory, "totalCompletedSessions" | "planId" | "sessions">[];
|
|
84
|
+
recentSessions: TRecentSession[];
|
|
69
85
|
} | {
|
|
70
86
|
status: 400 | 500;
|
|
71
87
|
message?: string;
|
|
@@ -56,7 +56,7 @@ const calculateExerciseScore = (param) => {
|
|
|
56
56
|
const avgIntensity = calculateAverageIntensity(completedSets, exercise, user);
|
|
57
57
|
const setQuality = calculateSetQuality(completedSets);
|
|
58
58
|
// Calculate muscle fatigue scores
|
|
59
|
-
const muscleScores = calculateMuscleScores(exercise, completedSets, totalVolume);
|
|
59
|
+
const muscleScores = calculateMuscleScores(exercise, completedSets, totalVolume, user);
|
|
60
60
|
// Final score composition
|
|
61
61
|
const volumeComponent = normalizeVolume(totalVolume, exercise, user) * 0.35;
|
|
62
62
|
const intensityComponent = avgIntensity * 0.35;
|
|
@@ -231,18 +231,22 @@ const calculateSetQuality = (record) => {
|
|
|
231
231
|
qualityScore += 3;
|
|
232
232
|
return Math.min(100, Math.max(0, qualityScore));
|
|
233
233
|
};
|
|
234
|
-
const calculateMuscleScores = (exercise, record, totalVolume) => {
|
|
234
|
+
const calculateMuscleScores = (exercise, record, totalVolume, user) => {
|
|
235
235
|
const muscleScores = {};
|
|
236
236
|
const volumePerSet = totalVolume / record.length;
|
|
237
|
+
// Normalize volume by bodyweight if available
|
|
238
|
+
const normalizedVolumePerSet = user.weightKg
|
|
239
|
+
? volumePerSet / (user.weightKg * 10)
|
|
240
|
+
: volumePerSet / 500; // Fallback to absolute scale
|
|
237
241
|
// Primary muscles take 70% of the fatigue
|
|
238
242
|
exercise.primaryMuscles.forEach((muscle) => {
|
|
239
|
-
const baseFatigue = Math.min(100,
|
|
243
|
+
const baseFatigue = Math.min(100, normalizedVolumePerSet * 70);
|
|
240
244
|
const setMultiplier = Math.min(1.5, 1 + (record.length - 1) * 0.15);
|
|
241
245
|
muscleScores[muscle] = Math.min(100, baseFatigue * setMultiplier);
|
|
242
246
|
});
|
|
243
247
|
// Secondary muscles take 30% of the fatigue
|
|
244
248
|
exercise.secondaryMuscles.forEach((muscle) => {
|
|
245
|
-
const baseFatigue = Math.min(100,
|
|
249
|
+
const baseFatigue = Math.min(100, normalizedVolumePerSet * 30);
|
|
246
250
|
const setMultiplier = Math.min(1.3, 1 + (record.length - 1) * 0.1);
|
|
247
251
|
muscleScores[muscle] = Math.min(100, baseFatigue * setMultiplier);
|
|
248
252
|
});
|