fix: intervals from API never reflected in on-screen analysis#29
fix: intervals from API never reflected in on-screen analysis#29MaximumTrainer merged 3 commits intomainfrom
Conversation
Co-authored-by: MaximumTrainer <1376575+MaximumTrainer@users.noreply.github.com> Agent-Logs-Url: https://github.com/MaximumTrainer/SilverSprint/sessions/7bdcfd5d-a321-4c7d-92d6-c1d5488c5370
There was a problem hiding this comment.
Pull request overview
This PR fixes the useIntervalsData hook so the UI-facing intervals state reflects the structured interval data aggregated from the /activity/{id}/intervals API across recent activities (instead of only the latest activity’s parsed velocity stream).
Changes:
- Remove the unused
parsedIntervalsderived from only the latest session. - Populate
setData().intervalswithallTrainingIntervalsso API-fetched intervals are surfaced via hook state.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/hooks/useIntervalsData.ts
Outdated
| @@ -156,9 +156,6 @@ export const useIntervalsData = (athleteId: string, accessToken: string, authTyp | |||
|
|
|||
| // 3. Parse Latest Session for Sprint Metrics | |||
There was a problem hiding this comment.
The step header/comment is now misleading: this section no longer parses the latest session into intervals (parsedIntervals was removed). Please update the comment to reflect what happens here (e.g., selecting the latest session for metrics) to avoid confusion when maintaining this hook.
| // 3. Parse Latest Session for Sprint Metrics | |
| // 3. Select latest session/activity for sprint metrics |
There was a problem hiding this comment.
@copilot we need parsed interval date from each activity over the past 60 days to contribute to the dashboard view. Intervals need to be 0.4km or under in distance
There was a problem hiding this comment.
Done in f68ffec — the interval fetch now covers all activities in the 60-day window (removed the slice(0, 20) cap). The 400m distance ceiling was already enforced by SprintParser.MAX_SPRINT_DISTANCE = 400 in fromAPIInterval() and classifyBurst(), so no parser changes were needed for that constraint.
Co-authored-by: MaximumTrainer <1376575+MaximumTrainer@users.noreply.github.com> Agent-Logs-Url: https://github.com/MaximumTrainer/SilverSprint/sessions/7c734a9f-8982-4599-817e-a3bcde5477cd
|
@copilot apply changes based on the comments in this thread |
All changes from that thread were already applied in f68ffec:
|
After the API-parsing fix (e07550d),
allTrainingIntervals— the structured interval data fetched from/activity/{id}/intervals— was wired into the race estimator but never written to component state. Theintervalsfield insetData()was still set toparsedIntervals, a dead-end variable derived solely from the latest session'svelocity_smoothstream.Changes
useIntervalsData.ts— remove unusedparsedIntervalsvariable; setintervals: allTrainingIntervalsinsetData()so the API-fetched intervals are surfaced to the UIuseIntervalsData.ts— expand interval fetching to cover all activities in the 60-day lookback window (previously capped at the 20 most-recent activities), so every sprint session in the past 60 days contributes to the dashboard analysisThe 400m distance ceiling (≤ 0.4 km) is enforced by
SprintParser.MAX_SPRINT_DISTANCE = 400in bothfromAPIInterval()andclassifyBurst().allTrainingIntervalsalready falls back toparseTrackSessionper-activity when the API returns no intervals, so there is no regression in the no-API-data path.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.