@dgpholdings/greatoak-shared 1.1.19 → 1.1.21
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/scoring.utils.d.ts +16 -13
- package/dist/utils/scoring.utils.js +25 -15
- package/package.json +1 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TRefinedRecord } from "./record.utils";
|
|
2
|
+
type TUserProfile = {
|
|
3
3
|
age?: number;
|
|
4
4
|
gender?: "male" | "female" | "non-binary" | "unspecified";
|
|
5
5
|
weightKg?: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The score represents the training stimulus or workload stress generated by a specific set of exercise inputs.
|
|
9
|
+
* in short: Training Stress Score (TSS)
|
|
10
|
+
* We can use the score for:
|
|
11
|
+
1.Tracking session intensity or set difficulty over time
|
|
12
|
+
2. Deciding muscle recovery readiness
|
|
13
|
+
3. Creating training summaries, like:
|
|
14
|
+
- Daily workload
|
|
15
|
+
- Volume comparisons
|
|
16
|
+
- Weekly fatigue trends
|
|
17
|
+
*/
|
|
18
|
+
export declare const computeScoreFromRecord: (record: TRefinedRecord, userProfile?: TUserProfile) => number;
|
|
19
|
+
export {};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeScoreFromRecord =
|
|
3
|
+
exports.computeScoreFromRecord = void 0;
|
|
4
4
|
const time_util_1 = require("./time.util");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The score represents the training stimulus or workload stress generated by a specific set of exercise inputs.
|
|
7
|
+
* in short: Training Stress Score (TSS)
|
|
8
|
+
* We can use the score for:
|
|
9
|
+
1.Tracking session intensity or set difficulty over time
|
|
10
|
+
2. Deciding muscle recovery readiness
|
|
11
|
+
3. Creating training summaries, like:
|
|
12
|
+
- Daily workload
|
|
13
|
+
- Volume comparisons
|
|
14
|
+
- Weekly fatigue trends
|
|
15
|
+
*/
|
|
16
|
+
const computeScoreFromRecord = (record, userProfile) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7
18
|
if (!record.isDone)
|
|
8
19
|
return 0;
|
|
9
20
|
// Determine load and effortFactor from record based on type
|
|
@@ -19,22 +30,20 @@ function computeScoreFromRecord(record, recordType, userProfile) {
|
|
|
19
30
|
effortFactor = 10 - rir; // lower RIR means more effort
|
|
20
31
|
}
|
|
21
32
|
// Step 2: Determine load
|
|
22
|
-
switch (
|
|
33
|
+
switch (record.type) {
|
|
23
34
|
case "weight-reps": {
|
|
24
|
-
|
|
25
|
-
const reps = (_d = record.reps) !== null && _d !== void 0 ? _d : 0;
|
|
26
|
-
load = kg * reps;
|
|
35
|
+
load = record.kg * record.reps;
|
|
27
36
|
break;
|
|
28
37
|
}
|
|
29
38
|
case "duration": {
|
|
30
|
-
const durationSecs = (0, time_util_1.mmssToSecs)((
|
|
31
|
-
const auxWeight = (
|
|
39
|
+
const durationSecs = (0, time_util_1.mmssToSecs)((_c = record.durationSecs) !== null && _c !== void 0 ? _c : "00:00");
|
|
40
|
+
const auxWeight = (_d = record.auxWeightKg) !== null && _d !== void 0 ? _d : 0;
|
|
32
41
|
load = auxWeight > 0 ? auxWeight * durationSecs : durationSecs;
|
|
33
42
|
break;
|
|
34
43
|
}
|
|
35
|
-
case "
|
|
36
|
-
const reps = (
|
|
37
|
-
const auxWeight = (
|
|
44
|
+
case "reps-only": {
|
|
45
|
+
const reps = (_e = record.reps) !== null && _e !== void 0 ? _e : 0;
|
|
46
|
+
const auxWeight = (_f = record.auxWeightKg) !== null && _f !== void 0 ? _f : 0;
|
|
38
47
|
load = auxWeight > 0 ? auxWeight * reps : reps;
|
|
39
48
|
break;
|
|
40
49
|
}
|
|
@@ -42,8 +51,9 @@ function computeScoreFromRecord(record, recordType, userProfile) {
|
|
|
42
51
|
return 0;
|
|
43
52
|
}
|
|
44
53
|
return computeFinalScore(load, effortFactor, userProfile);
|
|
45
|
-
}
|
|
46
|
-
|
|
54
|
+
};
|
|
55
|
+
exports.computeScoreFromRecord = computeScoreFromRecord;
|
|
56
|
+
const computeFinalScore = (load, effortFactor, userProfile) => {
|
|
47
57
|
const base = Math.log10(1 + Math.max(0, load));
|
|
48
58
|
const effortBoost = 1 + Math.min(effortFactor, 10) * 0.05;
|
|
49
59
|
// Optional scaling
|
|
@@ -57,4 +67,4 @@ function computeFinalScore(load, effortFactor, userProfile) {
|
|
|
57
67
|
adjustment *= normalizedWeight / userProfile.weightKg;
|
|
58
68
|
}
|
|
59
69
|
return base * effortBoost * adjustment;
|
|
60
|
-
}
|
|
70
|
+
};
|