Skip to content

Improve leaderboard pagination to preserve loaded users during real-time updates (Issue #227)#271

Open
anshul23102 wants to merge 2 commits into
indresh404:mainfrom
anshul23102:fix/227-leaderboard-pagination-performance
Open

Improve leaderboard pagination to preserve loaded users during real-time updates (Issue #227)#271
anshul23102 wants to merge 2 commits into
indresh404:mainfrom
anshul23102:fix/227-leaderboard-pagination-performance

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Summary

Prevent real-time listener from resetting paginated data. When initial leaderboard updates fire, update only the first batch of users while preserving any data loaded via pagination. This ensures that users retain their pagination state while still seeing real-time rank updates for the top 50.

Changes

  • Modify real-time listener to merge initial batch with existing paginated data
  • Preserve all users loaded beyond the first 50 when updating from real-time listener
  • Prevent list resets during routine real-time updates

Testing

  1. Navigate to the GitRank leaderboard page
  2. View the initial 50 users
  3. Click "Load More" to fetch the next 50 users (total 100 displayed)
  4. Wait for a few moments to allow real-time listener to fire
  5. Verify that users still see all 100 users instead of list resetting to 50
  6. Verify that ranks in the initial 50 update in real-time if there are changes
  7. Test with different language filters to ensure pagination is preserved correctly

Type of Change

  • Performance optimization
  • Bug fix

Contributor Declaration

This contribution is original work and I have the right to contribute this code to the project. I understand that the project is licensed under its respective license and my contributions will be available under the same license terms.

Closes #227

…ime updates (Issue indresh404#227)

Prevent real-time listener from resetting paginated data. When initial leaderboard updates fire, update only the first batch of users while preserving any data loaded via pagination. This ensures that users retain their pagination state while still seeing real-time rank updates for the top 50.

Changes:
- Modify real-time listener to merge initial batch with existing paginated data
- Preserve all users loaded beyond the first 50 when updating from real-time listener
- Prevent O(N) list resets during routine real-time updates

Fixes indresh404#227
@anshul23102 anshul23102 requested a review from indresh404 as a code owner June 3, 2026 19:49
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ranker-hub Error Error Jun 5, 2026 4:19pm

@github-actions github-actions Bot added bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jun 3, 2026
@anshul23102
Copy link
Copy Markdown
Contributor Author

Suggested Labels

For maintainer review and categorization:

  • performance (Performance improvement)
  • frontend (UI state management)
  • level:advanced (Advanced complexity)

Improves leaderboard pagination to preserve loaded users during real-time updates.

@indresh404
Copy link
Copy Markdown
Owner

Solve Merge Conflict

Merge conflict in src/pages/GitRank.jsx resolved by maintaining the improved
pagination logic that:
- Properly ranks initial batch of users
- Preserves paginated data beyond first 50 items
- Sets up pagination cursors correctly

This ensures loaded users are preserved during real-time updates while
maintaining correct pagination behavior.

Related: indresh404#227
@anshul23102
Copy link
Copy Markdown
Contributor Author

Hi @indresh404,

I've resolved the merge conflict in this PR. The conflict in src/pages/GitRank.jsx has been addressed by keeping the improved pagination logic that:

Changes Preserved:

  • Proper variable naming (rankedInitialUsers instead of simple ranked)
  • Logic to preserve paginated data beyond the first 50 items
  • Correct pagination cursor setup

Why This Matters:
The fix ensures that loaded users are preserved during real-time updates, preventing the loss of paginated data when new updates arrive from Firestore listeners.

Branch Status:

  • Merge conflict resolved: ✅
  • All changes committed: ✅
  • Branch is now up-to-date with main: ✅

The branch is ready for review and merging.

Closes #227

@indresh404
Copy link
Copy Markdown
Owner

If your PR still shows the old failed Vercel check, please rebase (or merge the latest main branch into your branch) and push again to trigger a fresh deployment/check run.

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

Labels

bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] Leaderboard Pagination Re-ranks All Previously Loaded Users on Each Load

2 participants