fix(analytics): include minutes for time-based set volume stats#223
Open
evan188199-tech wants to merge 1 commit into
Open
fix(analytics): include minutes for time-based set volume stats#223evan188199-tech wants to merge 1 commit into
evan188199-tech wants to merge 1 commit into
Conversation
The per-exercise volume route read time-based sets as `set.valuesSec[0]`, which had two problems: 1. Hardcoded index 0 — wrong when TIME isn't the first column (e.g. types ["REPS","TIME"] keeps seconds at valuesSec[1]). 2. Only seconds were counted; valuesInt[timeIndex] (the minutes) was dropped entirely. A 3:00 plank (valuesInt:[3], valuesSec:[0]) read valuesSec[0] = 0 and was skipped by the volume > 0 guard, so it contributed zero volume while a 0:30 plank contributed 30. Compute the full duration in seconds (minutes*60 + seconds) and read it from the correct timeIndex. Fixes Snouzy#222
|
Someone is attempting to deploy a commit to the Workoutcool Team Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
此 PR 由 GLM-5.2 修复。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Per-exercise volume statistics (
/api/exercises/[id]/statistics/volume) dropped the minutes for time-based sets and read from the wrong array index, so time-based exercises got wildly wrong volume numbers — a 3:00 plank showed 0 volume while a 0:30 plank showed 30.This is a bug I found while auditing the analytics code (not covered by any existing issue/PR).
Root cause
A TIME column stores two values at the same column index (see
workout-session-set.tsx):valuesInt[columnIndex]= minutesvaluesSec[columnIndex]= secondsThe volume route read time-based sets like this:
Two problems:
valuesSec[0]— wrong when TIME isn't the first column (types: ["REPS","TIME"]keeps seconds atvaluesSec[1]).valuesInt:[3], valuesSec:[0]) hit the falsyset.valuesSec[0]guard and was skipped (volume = 0), while a 0:30 plank gotvolume = 30.Fix
Reads from
timeIndex(not a hardcoded 0), adds the minutes back in, and uses a non-falsy guard so a whole-minute entry isn't dropped. The downstreamvolume > 0check still correctly skips genuinely-empty entries (0 min + 0 sec).Fixes #222.