Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 7x 7x 7x 12x 12x 9x 9x 9x 9x 9x 9x 10x 10x 9x 12x 7x 7x | import type { SetLog, MovementPattern } from '@strengthsys/shared';
export interface VolumeResult {
total_volume: number;
per_movement_pattern: Partial<Record<MovementPattern, number>>;
}
/**
* Calculate total training volume and breakdown per movement pattern.
* Volume = weight_kg × reps for each completed set.
* For exercises with multiple movement patterns, volume is split evenly.
*/
export function calculateVolume(sets: SetLog[]): VolumeResult {
let total_volume = 0;
const per_movement_pattern: Partial<Record<MovementPattern, number>> = {};
for (const set of sets) {
if (set.skipped) continue;
if (set.actual_weight_kg == null || set.actual_reps == null) continue;
const setVolume = set.actual_weight_kg * set.actual_reps;
total_volume += setVolume;
const patterns = set.movement_patterns;
if (patterns.length > 0) {
const share = setVolume / patterns.length;
for (const pattern of patterns) {
per_movement_pattern[pattern] = (per_movement_pattern[pattern] ?? 0) + share;
}
}
}
return { total_volume, per_movement_pattern };
}
|