Skip to content

Feat/leaderboard#248

Merged
dDevAhmed merged 3 commits into
DigiNodes:mainfrom
nafsonig:feat/leaderboard
May 30, 2026
Merged

Feat/leaderboard#248
dDevAhmed merged 3 commits into
DigiNodes:mainfrom
nafsonig:feat/leaderboard

Conversation

@nafsonig
Copy link
Copy Markdown
Contributor

What I changed

  • leaderboard.service.ts
    • updateScore now uses a Redis pipeline for the two ZADD calls.
    • Added bulkUpdateScores(users, chunkSize) to pipeline updates in configurable chunks.
  • leaderboard.refresh.job.ts
    • Replaced the per-user updateScore loop with a single call to bulkUpdateScores.
  • Tests added:
    • leaderboard.refresh.job.spec.ts — validates the refresh job clears leaderboards and calls bulkUpdateScores with DB users.

Why

  • Reduces roundtrips and alleviates the effective O(N^2)-style cost when rebuilding leaderboards by batching Redis ZADD operations (especially important for large N). The refresh job now performs chunked pipelined writes, making it efficient and suitable for background execution.

Next steps (local)

  • Run the new tests:
npm install
npm test -- src/modules/leaderboard/leaderboard.refresh.job.spec.ts
  • Run full test suite if you want broader verification:
npm test

Would you like me to run the tests here and iterate on any failures?

Completed: Verify with protocol invariants (3/3)

Made changes.

closes #195

@dDevAhmed
Copy link
Copy Markdown
Contributor

resolve conflicts @nafsonig

@dDevAhmed dDevAhmed merged commit c5d179b into DigiNodes:main May 30, 2026
4 of 5 checks passed
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.

Leaderboard calculation O(N^2)

2 participants