Skip to content

Weekly XP chart on Settings → Usage always renders zero-height bars (reads detail.xp, which no writer ever sets) #858

Description

@namann5

What happened?

The "Weekly XP" chart on the Settings → Usage page (src/app/(app)/settings/usage/page.tsx) always renders zero-height bars for every week, even for users with recent XP activity.

The chart is fed by getWeeklyXp, which sums the xp key from each activity row's detail column:

// usage/page.tsx:126
weeks[key] = (weeks[key] || 0) + Number(e.detail?.xp ?? 0);

But no code path in the repo ever writes a detail.xp field. I grepped every activity_log insert site — the actual keys written are:

  • pr_mergeddetail: { recId, repo, prNumber, xpAwarded } (process-pr-event.ts:453)
  • claimdetail: { issueId } / { recId } (issues.ts:376, recommendations.ts:172)
  • help_dispatchdetail: { helpRequestId, fromUserId } (help-dispatch.ts:91)
  • xp_tripwiredetail: { threshold, priorTodayTotal, triggeringDelta, source, refId } (events.ts:126-133)
  • claim_reset_stale / claim_warning_staledetail: { recId, ... } (maintenance.ts:390, 423)

So e.detail?.xp is always undefined, Number(undefined ?? 0) is always 0, max in XpChart stays at the 1 fallback, and every bar renders 0px tall. The two stat cards ("XP today" / "XP this week") are correct — only the chart is dead.

Steps to Reproduce

  1. Sign in and earn XP (merge a PR, claim an issue, get mentor-verified, trip the daily cap).
  2. Navigate to Settings → Usage (/settings/usage).
  3. Observe the weekly XP bar chart: all 12 bars are flat/empty despite real activity entries and nonzero "XP this week".

Expected Behavior

The chart should sum the actual XP-bearing fields per event kind (e.g. xpAwarded for pr_merged, triggeringDelta for tripwires, the level-up delta for xp audit events), or the writers should store a normalized xp amount. Bars should reflect real weekly XP.

Where does this occur?

Contributor Dashboard

Environment

Not environment-specific — reproducible in any deployment.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions