feat: add reputation leaderboard command with pagination#52
Conversation
First page shows the top 5 and bottom 5 with a count of users in between. Subsequent pages walk the full ranking in chunks of 10 (1-10, 11-20, ...). Same navigation UX as the rep logs list.
The summary already covers the top 5, so the first detail page now shows ranks 6–15 (then 16–25, …). When everyone fits in the summary (≤10 ranked users), there are no detail pages and the next button stays disabled.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24aa562fce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let start = SUMMARY_TOP + detail_page * ITEMS_PER_PAGE; | ||
| let end = (start + ITEMS_PER_PAGE).min(entries.len()); | ||
| let slice = if start < entries.len() { &entries[start..end] } else { &[][..] }; |
There was a problem hiding this comment.
Exclude bottom summary rows from detail pages
Detail pagination currently slices from SUMMARY_TOP through entries.len() (start..end), so once there are more than SUMMARY_TOP + SUMMARY_BOTTOM users, the final detail page(s) include the same bottom 5 users already shown on the summary page. For example, with 25 users, page 2 repeats ranks 21–25 instead of only showing the “in-between” users. This makes the paginated output inconsistent and duplicates leaderboard rows; cap detailed slices (and page count) at entries.len() - SUMMARY_BOTTOM when summary mode is active.
Useful? React with 👍 / 👎.
Summary
Adds a new
/rep_leaderboardcommand that displays a ranked leaderboard of users by total reputation. The leaderboard supports pagination with a summary view showing top 5 and bottom 5 users, plus detailed pages for users in between.Changes
New command:
rep_leaderboardinsrc/commands/reputation/cmd_leaderboard.rsNew data type:
LeaderboardEntrystruct insrc/commands/reputation.rsreceiver_id,total_rep, andlog_countfor each ranked userEmbed variants: Extended
ReputationEmbedenum insrc/embeds/reputation/rep_embed.rsLeaderboardSummary: Shows top/bottom entries with middle countLeaderboardPage: Shows detailed page of entries with rank rangerank_prefix()andrender_entries()for consistent formatting with medal emojis (🥇🥈🥉) for top 3Module registration: Added
cmd_leaderboardmodule declaration and command registration insrc/commands/reputation.rsandsrc/bot.rsImplementation Details
sqlx::query_as!()with strongly-typedLeaderboardEntrystruct for database accessDeferredInteractionStreamwith proper permission checkshttps://claude.ai/code/session_01DMBDUREAZP7tfAwmp2xeLo