Bug
Per-exercise volume statistics (/api/exercises/[id]/statistics/volume) drop the minutes for time-based sets and read from the wrong array index, so time-based exercises get wildly wrong volume numbers — a 3:00 plank can show 0 volume.
How TIME data is stored
A TIME column stores two values at the same column index (see `workout-session-set.tsx`):
- `valuesInt[columnIndex]` = minutes
- `valuesSec[columnIndex]` = seconds
e.g. a 3 min 00 sec plank with a single TIME column → `types: ["TIME"]`, `valuesInt: [3]`, `valuesSec: [0]`.
The bug
In `app/api/exercises/[exerciseId]/statistics/volume/route.ts`:
```ts
const timeIndex = set.types.indexOf("TIME");
// ...
} else if (timeIndex !== -1 && set.valuesSec && set.valuesSec[0]) {
volume = set.valuesSec[0]; // (1) wrong index, (2) only seconds
}
```
Two problems:
- Hardcoded `valuesSec[0]` — should be `valuesSec[timeIndex]`. When TIME isn't the first column (e.g. `types: ["REPS", "TIME"]`) the seconds are at `valuesSec[1]`, but the code reads index 0.
- Minutes are ignored entirely. Only `valuesSec` is read; `valuesInt[timeIndex]` (the minutes) is never added. A 3:00 plank (`valuesInt:[3], valuesSec:[0]`) reads `valuesSec[0] = 0` → volume = 0, and is skipped by the `> 0` guard below. Meanwhile a 0:30 plank gets `volume = 30`.
Fix
Total duration in seconds:
```ts
} else if (timeIndex !== -1 && (set.valuesInt || set.valuesSec)) {
const minutes = set.valuesInt?.[timeIndex] ?? 0;
const seconds = set.valuesSec?.[timeIndex] ?? 0;
volume = minutes * 60 + seconds;
}
```
I have a PR ready.
Bug
Per-exercise volume statistics (
/api/exercises/[id]/statistics/volume) drop the minutes for time-based sets and read from the wrong array index, so time-based exercises get wildly wrong volume numbers — a 3:00 plank can show 0 volume.How TIME data is stored
A TIME column stores two values at the same column index (see `workout-session-set.tsx`):
e.g. a 3 min 00 sec plank with a single TIME column → `types: ["TIME"]`, `valuesInt: [3]`, `valuesSec: [0]`.
The bug
In `app/api/exercises/[exerciseId]/statistics/volume/route.ts`:
```ts
const timeIndex = set.types.indexOf("TIME");
// ...
} else if (timeIndex !== -1 && set.valuesSec && set.valuesSec[0]) {
volume = set.valuesSec[0]; // (1) wrong index, (2) only seconds
}
```
Two problems:
Fix
Total duration in seconds:
```ts
} else if (timeIndex !== -1 && (set.valuesInt || set.valuesSec)) {
const minutes = set.valuesInt?.[timeIndex] ?? 0;
const seconds = set.valuesSec?.[timeIndex] ?? 0;
volume = minutes * 60 + seconds;
}
```
I have a PR ready.