Skip to content

Add new leaderboard entries chart#463

Merged
tudddorrr merged 1 commit intodevelopfrom
leaderboard-entries-chart
Feb 18, 2026
Merged

Add new leaderboard entries chart#463
tudddorrr merged 1 commit intodevelopfrom
leaderboard-entries-chart

Conversation

@tudddorrr
Copy link
Collaborator

No description provided.

@tudddorrr tudddorrr added the enhancement New feature or request label Feb 18, 2026
@claude
Copy link

claude bot commented Feb 18, 2026

PR Review: Add new leaderboard entries chart


🔴 Code Quality / Potential Bugs

Sorting comparator uses || instead of ?? (line 44)

.sort((keyA, keyB) =>
  (payload.leaderboards[keyB] || payload.change[keyB]) -
  (payload.leaderboards[keyA] || payload.change[keyA])
)

When a leaderboard has 0 new entries, payload.leaderboards[keyB] is falsy, so the sort falls back to payload.change[keyB] — a percentage change value. This mixes counts and percentages in the same comparison, producing incorrect sort order for any zero-entry leaderboard. Use ?? 0 instead:

.sort((keyA, keyB) =>
  (payload.leaderboards[keyB] ?? 0) -
  (payload.leaderboards[keyA] ?? 0)
)

🟡 Potential Bugs

Unsafe property access on payload.leaderboards[key] (line 56)

{payload.leaderboards[key].toLocaleString()}

Keys are sourced from Object.keys(payload.leaderboards), so this is safe for the leaderboards map. However, the sort comparator on line 44 falls back to payload.change[keyB] as if a key could exist in change but not in leaderboards. If the backend can return asymmetric records, this will throw at .toLocaleString(). Either document/enforce that both maps always have identical keys, or add a guard: (payload.leaderboards[key] ?? 0).toLocaleString().


🔵 Minor

Fragment key uses array index instead of the stable leaderboard name (line 46)

<Fragment key={idx}>

The leaderboard name (key) is already available and is the natural stable identifier here:

<Fragment key={key}>

@tudddorrr tudddorrr merged commit b5140f4 into develop Feb 18, 2026
5 checks passed
@tudddorrr tudddorrr deleted the leaderboard-entries-chart branch February 18, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant