feat(chart): покадровый график — точка на подход, линия максимального веса, счётчик подходов
This commit is contained in:
@@ -167,17 +167,21 @@ export function getExerciseChart(exerciseName, clientId = null) {
|
||||
for (const ex of w.exercises || []) {
|
||||
if (!variantNames.has(normalizeName(ex.name))) continue;
|
||||
let maxWeight = 0, totalReps = 0;
|
||||
const sets = []; // каждый подход отдельно: точка на графике
|
||||
for (const s of ex.sets || []) {
|
||||
const wgt = s.isDropset && s.subSets?.length
|
||||
? Math.max(...s.subSets.map(x => parseFloat(x.weight) || 0))
|
||||
: (parseFloat(s.weight) || 0);
|
||||
if (wgt > maxWeight) maxWeight = wgt;
|
||||
totalReps += s.isDropset && s.subSets?.length
|
||||
? s.subSets.reduce((a, x) => a + (parseInt(x.reps) || 0), 0)
|
||||
: (parseInt(s.reps) || 0);
|
||||
const parts = s.isDropset && s.subSets?.length
|
||||
? s.subSets
|
||||
: [s];
|
||||
for (const p of parts) {
|
||||
const wgt = parseFloat(p.weight) || 0;
|
||||
const rps = parseInt(p.reps) || 0;
|
||||
if (wgt > 0 || rps > 0) sets.push({ weight: wgt, reps: rps });
|
||||
if (wgt > maxWeight) maxWeight = wgt;
|
||||
totalReps += rps;
|
||||
}
|
||||
}
|
||||
if (maxWeight > 0 || totalReps > 0) {
|
||||
points.push({ date: w.startTime, name: ex.name, maxWeight, totalReps });
|
||||
points.push({ date: w.startTime, name: ex.name, maxWeight, totalReps, sets });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user