Skip to content

fix: intervals from API never reflected in on-screen analysis#29

Merged
MaximumTrainer merged 3 commits intomainfrom
copilot/fix-intervals-reflection-issue
Mar 23, 2026
Merged

fix: intervals from API never reflected in on-screen analysis#29
MaximumTrainer merged 3 commits intomainfrom
copilot/fix-intervals-reflection-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

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. The intervals field in setData() was still set to parsedIntervals, a dead-end variable derived solely from the latest session's velocity_smooth stream.

Changes

  • useIntervalsData.ts — remove unused parsedIntervals variable; set intervals: allTrainingIntervals in setData() so the API-fetched intervals are surfaced to the UI
  • useIntervalsData.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 analysis
- const parsedIntervals = latestSession
-   ? SprintParser.parseTrackSession(latestSession)
-   : [];
  ...
- const activitiesForIntervals = activities.slice(0, 20);
+ const activitiesForIntervals = activities;
  ...
- intervals: parsedIntervals,
+ intervals: allTrainingIntervals,

The 400m distance ceiling (≤ 0.4 km) is enforced by SprintParser.MAX_SPRINT_DISTANCE = 400 in both fromAPIInterval() and classifyBurst(). allTrainingIntervals already falls back to parseTrackSession per-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.

Copilot AI changed the title [WIP] Fix intervals not being found and reflected in screen analysis fix: intervals from API never reflected in on-screen analysis Mar 23, 2026
Copilot AI requested a review from MaximumTrainer March 23, 2026 06:40
@MaximumTrainer MaximumTrainer requested a review from Copilot March 23, 2026 07:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 parsedIntervals derived from only the latest session.
  • Populate setData().intervals with allTrainingIntervals so API-fetched intervals are surfaced via hook state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -156,9 +156,6 @@ export const useIntervalsData = (athleteId: string, accessToken: string, authTyp

// 3. Parse Latest Session for Sprint Metrics
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 3. Parse Latest Session for Sprint Metrics
// 3. Select latest session/activity for sprint metrics

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MaximumTrainer
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

All changes from that thread were already applied in f68ffec:

  • Comment at line 157 updated to accurately describe what that step does
  • Interval fetch now covers all activities in the 60-day window (no slice(0, 20) cap)
  • The 400m (≤ 0.4km) distance filter was already enforced by SprintParser.MAX_SPRINT_DISTANCE = 400 in both fromAPIInterval() and classifyBurst()

@MaximumTrainer MaximumTrainer marked this pull request as ready for review March 23, 2026 07:27
@MaximumTrainer MaximumTrainer merged commit b3a6b10 into main Mar 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants