@dgpholdings/greatoak-shared 1.1.61 → 1.1.62
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.js +4 -13
- package/package.json +1 -1
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.calculateExerciseScore = void 0;
|
|
46
|
+
const time_util_1 = require("./time.util");
|
|
46
47
|
const calculateExerciseScore = (param) => {
|
|
47
48
|
const { exercise, record, user } = param;
|
|
48
49
|
// Filter only completed sets
|
|
@@ -67,16 +68,6 @@ const calculateExerciseScore = (param) => {
|
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
exports.calculateExerciseScore = calculateExerciseScore;
|
|
70
|
-
const parseMmSsToSeconds = (mmSs) => {
|
|
71
|
-
if (!mmSs)
|
|
72
|
-
return 0;
|
|
73
|
-
const parts = mmSs.split(":");
|
|
74
|
-
if (parts.length !== 2)
|
|
75
|
-
return 0;
|
|
76
|
-
const minutes = parseInt(parts[0]) || 0;
|
|
77
|
-
const seconds = parseInt(parts[1]) || 0;
|
|
78
|
-
return minutes * 60 + seconds;
|
|
79
|
-
};
|
|
80
71
|
const calculateTotalVolume = (record, user) => {
|
|
81
72
|
return record.reduce((total, set) => {
|
|
82
73
|
const weight = parseFloat(set.type === "weight-reps"
|
|
@@ -88,7 +79,7 @@ const calculateTotalVolume = (record, user) => {
|
|
|
88
79
|
const duration = set.type === "duration" ||
|
|
89
80
|
set.type === "cardio-machine" ||
|
|
90
81
|
set.type === "cardio-free"
|
|
91
|
-
?
|
|
82
|
+
? (0, time_util_1.mmssToSecs)(set.durationMmSs)
|
|
92
83
|
: 0;
|
|
93
84
|
if (set.type === "weight-reps") {
|
|
94
85
|
return total + reps * weight;
|
|
@@ -149,7 +140,7 @@ const calculateAverageIntensity = (record, exercise, user) => {
|
|
|
149
140
|
}
|
|
150
141
|
}
|
|
151
142
|
else if (set.type === "duration") {
|
|
152
|
-
const duration =
|
|
143
|
+
const duration = (0, time_util_1.mmssToSecs)(set.durationMmSs);
|
|
153
144
|
const weight = parseFloat(set.auxWeightKg) || 0;
|
|
154
145
|
baseIntensity = Math.min(100, duration * 1.5) / 100;
|
|
155
146
|
if (weight > 0) {
|
|
@@ -157,7 +148,7 @@ const calculateAverageIntensity = (record, exercise, user) => {
|
|
|
157
148
|
}
|
|
158
149
|
}
|
|
159
150
|
else if (set.type === "cardio-machine" || set.type === "cardio-free") {
|
|
160
|
-
const duration =
|
|
151
|
+
const duration = (0, time_util_1.mmssToSecs)(set.durationMmSs);
|
|
161
152
|
if (set.type === "cardio-machine") {
|
|
162
153
|
const avgSpeed = (parseFloat(set.speedMin) + parseFloat(set.speedMax)) / 2 || 0;
|
|
163
154
|
baseIntensity = Math.min(100, avgSpeed * 5.5) / 100;
|