feat(chart): покадровый график — точка на подход, линия максимального веса, счётчик подходов

This commit is contained in:
Иван Овчинников
2026-11-20 01:20:12 +03:00
parent 9fe1b41c2c
commit 50eba83266
3 changed files with 68 additions and 35 deletions
+12 -8
View File
@@ -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 });
}
}
}