union icon indicating copy to clipboard operation
union copied to clipboard

Leaderboard Only Shows Top 50 – Users Should See Their Own Rank

Open ismailkonvah opened this issue 10 months ago • 1 comments

Problem Statement Currently, the leaderboard on dashboard.union.build only displays the top 50 users based on their scores. However, users who are not in the top 50 have no way of knowing their rank.

Expected Behavior The leaderboard should continue displaying only the top 50 users as intended. Users outside the top 50 should still be able to see their exact rank and score somewhere on the dashboard.

Proposed Fix Modify the leaderboard query to: Fetch the top 50 users as usual. Additionally, fetch the current logged-in user's rank and score even if they are not in the top 50. Display the user’s position at the bottom of the leaderboard or in a separate section.

Technical Implementation Suggestions Database Query Update: Use SQL RANK() or ROW_NUMBER() to get the user’s position. Fetch the top 50 + current user's rank. Example SQL Query: SELECT name, score, RANK() OVER (ORDER BY score DESC) as rank FROM players WHERE rank <= 50 OR name = 'current_user';

Frontend Update: Show the user's rank and score below the leaderboard or in a "Your Rank" section.

Tasks Update the database query to always return the logged-in user's rank. Modify the frontend to display the user’s rank if they are outside the top 50. Test with various users (inside and outside the top 50). Deploy and verify changes.

Integration Context This update applies to the leaderboard on dashboard.union.build.

ismailkonvah avatar Feb 07 '25 18:02 ismailkonvah

@cor

ismailkonvah avatar Feb 12 '25 00:02 ismailkonvah

Agreed, will look into it. Thanks.

Swepool avatar Mar 04 '25 18:03 Swepool