Repository navigation
feature: Enable a configurable worldwide leaderboard #187
Copy link
Copy link
Open
Description
Activity
- addedgood first issueGood for newcomersGood for newcomersand removedgood first issueGood for newcomersGood for newcomers
on Aug 10, 2026 assign me
Reacted by github-actions🎉 Issue assigned to @1-DARK! Happy coding!
Worldwide Leaderboard:
Hi! I've implemented the worldwide leaderboard described in the issue. Before I open the PR, I'd like your feedback on the approach and a few small decisions. Are you satisfied with it, or would you like anything changed?
What I implemented
- Worldwide route/state.
/leaderboard/worldwideranks users from all countries together. The DB layer already supported theworldwideslug, so the work was around it. - Runtime limit. New variable
WORLDWIDE_LEADERBOARD_DISPLAY_LIMITcontrols how many users are shown. If it is missing, non-numeric, zero, negative or a decimal, it falls back to 100. Country leaderboards keep usingLEADERBOARD_DISPLAY_LIMIT(default 500). - Shared helper. A new
services/display-limit.tsis used by bothleaderboard-service.ts(page/API) andcalculate-leaderboard.ts, replacing duplicated limit logic. - Title fix. The result title is now "Worldwide" instead of the raw slug.
- UI. The worldwide page shows its own heading and description (English and Arabic). The worldwide SEO description no longer says "country ranking".
- Count fix. The "N country leaderboards" count on
/leaderboardno longer countsworldwideas a country. - Discoverability. A featured "Worldwide leaderboard" card sits at the top of
/leaderboard. It is removed from the normal country grid and country search. - Docs.
.env.exampleandREADME.mddocument the new variable (and the previously undocumentedLEADERBOARD_DISPLAY_LIMIT). - Tests. 9 new unit tests for the limit logic.
How I verified it
tsc --noEmit: clean- ESLint on the touched folders: clean
- Vitest: all tests pass (140)
- Manual check in the browser: [fill in after running locally: heading, count, ranking, limit variable]
How to try it
cp .env.example .envand setGITHUB_TOKENpnpm db:up && pnpm redis:up, thenpnpm leaderboard:calculateif the database is emptypnpm run dev, then open/leaderboardand click the Worldwide card- Set
WORLDWIDE_LEADERBOARD_DISPLAY_LIMIT=3, restart, and confirm only 3 users show
Questions for you
- Default limit. Is 100 a sensible fallback for worldwide, or would you prefer another number (for example 50 or 500)?
- Entry point. Is the featured card at the top of
/leaderboardthe right placement? Should I also add a link in the site header? - Cache behavior. The cache stores results per slug and slices to the current limit. Lowering the variable takes effect immediately, but raising it may need the cache to refresh first. Is that acceptable, or should the limit be part of the cache key?
- Arabic text. I wrote the new Arabic strings myself. Could a native speaker review them?
- Scope. Is there anything in the issue I missed, or anything you would like added (for example a worldwide link in the sitemap or a top-N note on the page)?
Notes
- No scoring logic or database code was changed.
- Worldwide is computed from existing user rows, so the background worker needs no extra work for it.
Thanks for taking a look. I'm happy to adjust anything before opening the PR.
Screnshots
- Worldwide route/state.
Hi @1-DARK
I think you already implemented the feature as expected.The answer of your questions:
- You can set the default limit to 100.
- No need for another link in the header, maybe in the future we refactor the whole leaderboard UI.
- You can use the same caching behavior, it is ok if the I change take a time to appear.
- In the localization: just make sure the same keys are exist in the all locales files(ar, en...) and you are fine to go.
- It will be good if you add the worldwide link to the sitemap if not added yet. otherwise, everything seems fine..



The leaderboard currently focuses on country-specific rankings. We should add support for a worldwide leaderboard that aggregates users globally and limits the number of displayed users through a runtime environment variable.
Tasks
worldwideleaderboard route/state in the leaderboard data flow.worldwide.WORLDWIDE_LEADERBOARD_DISPLAY_LIMIT) to control how many users are shown..env.exampleand relevant documentation with the new variable.Tip
🚀 Want to contribute?
Comment
assign meto be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨