@dgpholdings/greatoak-shared 1.2.18 → 1.2.20
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/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/scoring/calculateTotalVolume.d.ts +11 -0
- package/dist/utils/scoring/calculateTotalVolume.js +52 -0
- package/dist/utils/scoring/index.d.ts +1 -1
- package/dist/utils/scoring/index.js +3 -1
- package/dist/utils/scoring.utils.js +2 -39
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { toError } from "./toError.util";
|
|
|
8
8
|
export { generatePlanCode } from "./planCode.util";
|
|
9
9
|
export { maskEmail, isAnonymousEmail, isEmail } from "./email.utils";
|
|
10
10
|
export { NOOP } from "./noop.utils";
|
|
11
|
-
export { calculateExerciseScoreV2 } from "./scoring";
|
|
11
|
+
export { calculateExerciseScoreV2, calculateTotalVolume } from "./scoring";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateExerciseScoreV2 = exports.NOOP = exports.isEmail = exports.isAnonymousEmail = exports.maskEmail = exports.generatePlanCode = exports.toError = exports.slugifyText = exports.isDefinedNumber = exports.isDefined = exports.calculateExerciseScore = exports.countryToCurrencyCode = exports.getDaysAndHoursDifference = exports.isUserAllowedToUpdate = exports.mmssToSecs = exports.toNumber = void 0;
|
|
3
|
+
exports.calculateTotalVolume = exports.calculateExerciseScoreV2 = exports.NOOP = exports.isEmail = exports.isAnonymousEmail = exports.maskEmail = exports.generatePlanCode = exports.toError = exports.slugifyText = exports.isDefinedNumber = exports.isDefined = exports.calculateExerciseScore = exports.countryToCurrencyCode = exports.getDaysAndHoursDifference = exports.isUserAllowedToUpdate = exports.mmssToSecs = exports.toNumber = void 0;
|
|
4
4
|
var number_util_1 = require("./number.util");
|
|
5
5
|
Object.defineProperty(exports, "toNumber", { enumerable: true, get: function () { return number_util_1.toNumber; } });
|
|
6
6
|
var time_util_1 = require("./time.util");
|
|
@@ -28,3 +28,4 @@ var noop_utils_1 = require("./noop.utils");
|
|
|
28
28
|
Object.defineProperty(exports, "NOOP", { enumerable: true, get: function () { return noop_utils_1.NOOP; } });
|
|
29
29
|
var scoring_1 = require("./scoring");
|
|
30
30
|
Object.defineProperty(exports, "calculateExerciseScoreV2", { enumerable: true, get: function () { return scoring_1.calculateExerciseScoreV2; } });
|
|
31
|
+
Object.defineProperty(exports, "calculateTotalVolume", { enumerable: true, get: function () { return scoring_1.calculateTotalVolume; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TRecord, TUserMetric } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates total volume for a set of records.
|
|
4
|
+
*
|
|
5
|
+
* - weight-reps: reps * weight
|
|
6
|
+
* - reps-only: reps * (auxWeight || 30% of bodyweight)
|
|
7
|
+
* - duration: durationSecs * 10 * (1 + auxWeight/100)
|
|
8
|
+
* - cardio-machine: distance (m) * (1 + avgSpeed/20)
|
|
9
|
+
* - cardio-free: distance (m) * (1 + speed/20)
|
|
10
|
+
*/
|
|
11
|
+
export declare const calculateTotalVolume: (record: TRecord[], user: TUserMetric) => number;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateTotalVolume = void 0;
|
|
4
|
+
const time_util_1 = require("../time.util");
|
|
5
|
+
/**
|
|
6
|
+
* Calculates total volume for a set of records.
|
|
7
|
+
*
|
|
8
|
+
* - weight-reps: reps * weight
|
|
9
|
+
* - reps-only: reps * (auxWeight || 30% of bodyweight)
|
|
10
|
+
* - duration: durationSecs * 10 * (1 + auxWeight/100)
|
|
11
|
+
* - cardio-machine: distance (m) * (1 + avgSpeed/20)
|
|
12
|
+
* - cardio-free: distance (m) * (1 + speed/20)
|
|
13
|
+
*/
|
|
14
|
+
const calculateTotalVolume = (record, user) => {
|
|
15
|
+
return record.reduce((total, set) => {
|
|
16
|
+
const weight = parseFloat(set.type === "weight-reps"
|
|
17
|
+
? set.kg
|
|
18
|
+
: set.type === "duration" || set.type === "reps-only"
|
|
19
|
+
? set.auxWeightKg
|
|
20
|
+
: "0") || 0;
|
|
21
|
+
const reps = parseFloat(set.type === "weight-reps" || set.type === "reps-only" ? set.reps : "0") || 0;
|
|
22
|
+
const duration = set.type === "duration" ||
|
|
23
|
+
set.type === "cardio-machine" ||
|
|
24
|
+
set.type === "cardio-free"
|
|
25
|
+
? (0, time_util_1.mmssToSecs)(set.durationMmSs)
|
|
26
|
+
: 0;
|
|
27
|
+
if (set.type === "weight-reps") {
|
|
28
|
+
return total + reps * weight;
|
|
29
|
+
}
|
|
30
|
+
else if (set.type === "reps-only") {
|
|
31
|
+
const bodyweight = user.weightKg || 70;
|
|
32
|
+
const effectiveWeight = weight > 0 ? weight : bodyweight * 0.3;
|
|
33
|
+
return total + reps * effectiveWeight;
|
|
34
|
+
}
|
|
35
|
+
else if (set.type === "duration") {
|
|
36
|
+
const weightFactor = weight > 0 ? 1 + weight / 100 : 1;
|
|
37
|
+
return total + duration * 10 * weightFactor;
|
|
38
|
+
}
|
|
39
|
+
else if (set.type === "cardio-machine") {
|
|
40
|
+
const avgSpeed = (parseFloat(set.speedMin) + parseFloat(set.speedMax)) / 2 || 10;
|
|
41
|
+
const distance = parseFloat(set.distance || "0") || (avgSpeed * duration) / 3600;
|
|
42
|
+
return total + distance * 1000 * (1 + avgSpeed / 20);
|
|
43
|
+
}
|
|
44
|
+
else if (set.type === "cardio-free") {
|
|
45
|
+
const distance = parseFloat(set.distance) || 0;
|
|
46
|
+
const speed = distance / (duration / 3600);
|
|
47
|
+
return total + distance * 1000 * (1 + speed / 20);
|
|
48
|
+
}
|
|
49
|
+
return total;
|
|
50
|
+
}, 0);
|
|
51
|
+
};
|
|
52
|
+
exports.calculateTotalVolume = calculateTotalVolume;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* interface expects.
|
|
15
15
|
*/
|
|
16
16
|
import { TExercise, TRecord, TUserMetric } from "../../types";
|
|
17
|
+
export { calculateTotalVolume } from "./calculateTotalVolume";
|
|
17
18
|
interface IScoreResult {
|
|
18
19
|
score: number;
|
|
19
20
|
muscleScores: {
|
|
@@ -25,4 +26,3 @@ export declare const calculateExerciseScoreV2: (param: {
|
|
|
25
26
|
record: TRecord[];
|
|
26
27
|
user: TUserMetric;
|
|
27
28
|
}) => IScoreResult;
|
|
28
|
-
export {};
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
* interface expects.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.calculateExerciseScoreV2 = void 0;
|
|
18
|
+
exports.calculateExerciseScoreV2 = exports.calculateTotalVolume = void 0;
|
|
19
19
|
const calculateMuscleFatiue_1 = require("./calculateMuscleFatiue");
|
|
20
20
|
const calculateQualityScore_1 = require("./calculateQualityScore");
|
|
21
21
|
const helpers_1 = require("./helpers");
|
|
22
22
|
const parseRecords_1 = require("./parseRecords");
|
|
23
|
+
var calculateTotalVolume_1 = require("./calculateTotalVolume");
|
|
24
|
+
Object.defineProperty(exports, "calculateTotalVolume", { enumerable: true, get: function () { return calculateTotalVolume_1.calculateTotalVolume; } });
|
|
23
25
|
// ---------------------------------------------------------------------------
|
|
24
26
|
// Main Function — existing signature
|
|
25
27
|
// ---------------------------------------------------------------------------
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.calculateExerciseScore = void 0;
|
|
46
46
|
const time_util_1 = require("./time.util");
|
|
47
|
+
const scoring_1 = require("./scoring");
|
|
47
48
|
const calculateExerciseScore = (param) => {
|
|
48
49
|
const { exercise, record, user } = param;
|
|
49
50
|
// Filter only completed sets
|
|
@@ -52,7 +53,7 @@ const calculateExerciseScore = (param) => {
|
|
|
52
53
|
return { score: 0, muscleScores: {} };
|
|
53
54
|
}
|
|
54
55
|
// Calculate base performance metrics
|
|
55
|
-
const totalVolume = calculateTotalVolume(completedSets, user);
|
|
56
|
+
const totalVolume = (0, scoring_1.calculateTotalVolume)(completedSets, user);
|
|
56
57
|
const avgIntensity = calculateAverageIntensity(completedSets, exercise, user);
|
|
57
58
|
const setQuality = calculateSetQuality(completedSets);
|
|
58
59
|
// Calculate muscle fatigue scores
|
|
@@ -68,44 +69,6 @@ const calculateExerciseScore = (param) => {
|
|
|
68
69
|
};
|
|
69
70
|
};
|
|
70
71
|
exports.calculateExerciseScore = calculateExerciseScore;
|
|
71
|
-
const calculateTotalVolume = (record, user) => {
|
|
72
|
-
return record.reduce((total, set) => {
|
|
73
|
-
const weight = parseFloat(set.type === "weight-reps"
|
|
74
|
-
? set.kg
|
|
75
|
-
: set.type === "duration" || set.type === "reps-only"
|
|
76
|
-
? set.auxWeightKg
|
|
77
|
-
: "0") || 0;
|
|
78
|
-
const reps = parseFloat(set.type === "weight-reps" || set.type === "reps-only" ? set.reps : "0") || 0;
|
|
79
|
-
const duration = set.type === "duration" ||
|
|
80
|
-
set.type === "cardio-machine" ||
|
|
81
|
-
set.type === "cardio-free"
|
|
82
|
-
? (0, time_util_1.mmssToSecs)(set.durationMmSs)
|
|
83
|
-
: 0;
|
|
84
|
-
if (set.type === "weight-reps") {
|
|
85
|
-
return total + reps * weight;
|
|
86
|
-
}
|
|
87
|
-
else if (set.type === "reps-only") {
|
|
88
|
-
const bodyweight = user.weightKg || 70;
|
|
89
|
-
const effectiveWeight = weight > 0 ? weight : bodyweight * 0.3;
|
|
90
|
-
return total + reps * effectiveWeight;
|
|
91
|
-
}
|
|
92
|
-
else if (set.type === "duration") {
|
|
93
|
-
const weightFactor = weight > 0 ? 1 + weight / 100 : 1;
|
|
94
|
-
return total + duration * 10 * weightFactor;
|
|
95
|
-
}
|
|
96
|
-
else if (set.type === "cardio-machine") {
|
|
97
|
-
const avgSpeed = (parseFloat(set.speedMin) + parseFloat(set.speedMax)) / 2 || 10;
|
|
98
|
-
const distance = parseFloat(set.distance || "0") || (avgSpeed * duration) / 3600;
|
|
99
|
-
return total + distance * 1000 * (1 + avgSpeed / 20);
|
|
100
|
-
}
|
|
101
|
-
else if (set.type === "cardio-free") {
|
|
102
|
-
const distance = parseFloat(set.distance) || 0;
|
|
103
|
-
const speed = distance / (duration / 3600);
|
|
104
|
-
return total + distance * 1000 * (1 + speed / 20);
|
|
105
|
-
}
|
|
106
|
-
return total;
|
|
107
|
-
}, 0);
|
|
108
|
-
};
|
|
109
72
|
const calculateAverageIntensity = (record, exercise, user) => {
|
|
110
73
|
const intensities = record.map((set, index) => {
|
|
111
74
|
let baseIntensity = 0;
|