Skip to content

Fix: Strava canonical metric keys + re-scoring migration for 0-point activities#37

Merged
prazgaitis merged 2 commits intomainfrom
fix/strava-metric-keys-and-rescoring
Feb 15, 2026
Merged

Fix: Strava canonical metric keys + re-scoring migration for 0-point activities#37
prazgaitis merged 2 commits intomainfrom
fix/strava-metric-keys-and-rescoring

Conversation

@paulsclaw
Copy link
Copy Markdown
Collaborator

Fixes #35

Problem

Strava activities stored metrics as distance_miles/distance_km but scoring configs use miles/kilometers. Before commit 082141c, the scoring code did direct key lookup without alias resolution, resulting in 0 points for Strava activities.

The alias fix was deployed but existing activities were never re-scored.

Changes

1. packages/backend/lib/strava.ts

Now also sets canonical miles and kilometers keys in extractMetrics(), ensuring scoring works regardless of alias resolution.

2. Re-scoring migration

  • packages/backend/mutations/rescoreStrava.ts - Internal mutation that finds all Strava activities with 0 points and recalculates their scores
  • packages/backend/actions/rescoreStravaActivities.ts - Action wrapper
  • Supports dryRun mode to preview before applying
  • Updates both activity pointsEarned and userChallenges.totalPoints

Usage

After deploying, run via Convex dashboard:

rescoreStravaActivities({ challengeId: "js79t7qjg4sdehecxyngd3jjcs810wp1", dryRun: true })

Review output, then run with dryRun: false to apply.

…ation

1. Strava extractMetrics now also sets 'miles' and 'kilometers' keys
   alongside 'distance_miles' and 'distance_km', ensuring scoring works
   even without alias resolution.

2. Added rescoreStrava migration to fix existing activities that were
   scored with 0 points before the metric alias fix (082141c).
   Run with dryRun=true first to preview, then dryRun=false to apply.

Fixes #35
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
march-fitness-2025 Ready Ready Preview, Comment Feb 15, 2026 10:21pm

Request Review

@prazgaitis prazgaitis merged commit f2ebabf into main Feb 15, 2026
4 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.

Bug: Strava activities scored with 0 points due to metric key mismatch

2 participants