Skip to content

feature: Enable a configurable worldwide leaderboard #187

Description

@O2sa

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

  • Add support for a worldwide leaderboard route/state in the leaderboard data flow.
  • Query users across all countries when the selected leaderboard slug is worldwide.
  • Add a runtime environment variable (e.g., WORLDWIDE_LEADERBOARD_DISPLAY_LIMIT) to control how many users are shown.
  • Apply a sensible fallback limit when the runtime variable is missing or invalid.
  • Update .env.example and relevant documentation with the new variable.
  • Verify the UI handles the worldwide leaderboard title, count, and ranking correctly.

Tip

🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨

Activity

  1. 1-DARK commented on Oct 8, 2026

    @1-DARK
    Contributor

    assign me

  2. github-actions commented on Oct 8, 2026

    @github-actions

    🎉 Issue assigned to @1-DARK! Happy coding!

  3. 1-DARK commented on Oct 9, 2026

    @1-DARK
    Contributor

    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/worldwide ranks users from all countries together. The DB layer already supported the worldwide slug, so the work was around it.
    • Runtime limit. New variable WORLDWIDE_LEADERBOARD_DISPLAY_LIMIT controls how many users are shown. If it is missing, non-numeric, zero, negative or a decimal, it falls back to 100. Country leaderboards keep using LEADERBOARD_DISPLAY_LIMIT (default 500).
    • Shared helper. A new services/display-limit.ts is used by both leaderboard-service.ts (page/API) and calculate-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 /leaderboard no longer counts worldwide as 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.example and README.md document the new variable (and the previously undocumented LEADERBOARD_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

    1. cp .env.example .env and set GITHUB_TOKEN
    2. pnpm db:up && pnpm redis:up, then pnpm leaderboard:calculate if the database is empty
    3. pnpm run dev, then open /leaderboard and click the Worldwide card
    4. Set WORLDWIDE_LEADERBOARD_DISPLAY_LIMIT=3, restart, and confirm only 3 users show

    Questions for you

    1. Default limit. Is 100 a sensible fallback for worldwide, or would you prefer another number (for example 50 or 500)?
    2. Entry point. Is the featured card at the top of /leaderboard the right placement? Should I also add a link in the site header?
    3. 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?
    4. Arabic text. I wrote the new Arabic strings myself. Could a native speaker review them?
    5. 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

    Leaderboard index Worldwide page Limit applied

  4. O2sa commented on Oct 9, 2026

    @O2sa
    OwnerAuthor

    Hi @1-DARK
    I think you already implemented the feature as expected.

    The answer of your questions:

    1. You can set the default limit to 100.
    2. No need for another link in the header, maybe in the future we refactor the whole leaderboard UI.
    3. You can use the same caching behavior, it is ok if the I change take a time to appear.
    4. In the localization: just make sure the same keys are exist in the all locales files(ar, en...) and you are fine to go.
    5. It will be good if you add the worldwide link to the sitemap if not added yet. otherwise, everything seems fine..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions