Skip to content

feat: cap leaderboard at 100 entries and add integration tests - #853

Open
crookdev11 wants to merge 1 commit into
accesslayerorg:mainfrom
crookdev11:feat/leaderboard-100-entry-cap
Open

feat: cap leaderboard at 100 entries and add integration tests#853
crookdev11 wants to merge 1 commit into
accesslayerorg:mainfrom
crookdev11:feat/leaderboard-100-entry-cap

Conversation

@crookdev11

Copy link
Copy Markdown

Cap leaderboard endpoint at 100 entries

The GET /api/v1/creators/leaderboard endpoint previously
returned every creator in the database with no upper bound.
This PR enforces a hard cap of 100 entries and adds a
total_count field so clients can tell whether the list was
truncated.

What changed

  • httpGetCreatorLeaderboard now applies a
    LEADERBOARD_MAX_ENTRIES = 100 cap to every response
  • An optional ?limit query param is accepted and clamped to
    [1, 100] — any value above 100 is silently reduced to 100
  • The response now includes total_count, which always reflects
    the full number of creators in the database regardless of the
    effective limit

Response shape (before → after)

{
"success": true,
"data": {

  • "items": [...]
  • "items": [...], // max 100 entries
  • "total_count": 110
    }
    }

Tests added

creator-leaderboard-cap.integration.test.ts seeds 110 mock
creators with distinct holder counts and verifies:

  • Exactly 100 entries returned when 110 creators exist
  • Returned entries are the top 100 by holder count, descending
  • Rank fields run sequentially from 1 to 100
  • ?limit=200 and ?limit=9999 are both capped at 100
  • ?limit=10 returns only the top 10 entries
  • total_count is always 110 regardless of the limit param
  • The bottom 10 creators never appear in the response

Pre-existing fixes (required to unblock integration test runs)

  • Added missing STELLAR_AUTH_SECRET optional field to
    config.schema.ts
  • Added missing jwtAuth and httpGetWalletFollowing imports to
    wallets.routes.ts
  • Added diagnostics: { warnOnly: true } to jest.config.js so
    pre-existing type errors in unrelated modules don't prevent
    test suites from running

closes #770

- Add LEADERBOARD_MAX_ENTRIES (100) hard cap to httpGetCreatorLeaderboard
- Parse and clamp optional ?limit param to [1, 100]; values above 100
  are silently capped
- Add total_count field to response so clients can detect truncation
- Add integration test seeding 110 creators, asserting exactly 100
  returned, top 100 by holder count, limit param capping, total_count
- Update sort-order integration test to assert total_count field
- Fix missing STELLAR_AUTH_SECRET in config schema (pre-existing)
- Fix missing jwtAuth/httpGetWalletFollowing imports in wallets.routes.ts
- Add ts-jest diagnostics warnOnly to unblock integration test runs
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@crookdev11 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integration test for the leaderboard endpoint returning at most 100 creators regardless of total creator count

1 participant