Skip to content

Feature/add global ranking#120

Merged
jagdish-15 merged 11 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/add-global-ranking
Jun 9, 2026
Merged

Feature/add global ranking#120
jagdish-15 merged 11 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/add-global-ranking

Conversation

@Yashaswini-K-P

@Yashaswini-K-P Yashaswini-K-P commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR extends the /api/student/:username endpoint by adding the user's live LeetCode Global Ranking to the API response payload.

Previously, while problem metrics were tracked historically via GitHub repositories, the absolute global leaderboard ranking was not exposed to the student profile layout. This change fetches the most recent global ranking dynamically from the LeetCode API, updates the response body structure gracefully, and implements zero-value fallbacks if the upstream service is unreachable—ensuring complete backward compatibility.

Linked Issue

Fixes #92

Changes Made

  • Direct API Upstream Fetching: Configured fetchStudentHistory to initially hit the leetcode-api-dun.vercel.app wrapper to capture the live, un-mutated ranking integer on-demand.
  • Resilient Graceful Degradation: Added fallback error handling to default the ranking parameter to 0 or retrieve it sequentially from historical repositories if the upstream wrapper times out or fails.
  • Payload Extension: Modified the return utility signature to inject the root-level ranking key directly alongside username and history data to align with frontend consumption criteria.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally using Prettier
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

Screenshot 2026-06-07 134024

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

A maintainer will review your submission shortly.

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already depend on the same API wrapper for the sync workflow itself, if the API fails badly enough for ranking to become unavailable, the leaderboard sync/update process would already have much larger issues anyway. Because of that, the historical snapshot fallback mechanism feels a bit overengineered for this use case.

The fetch-student-info.js changes themselves make sense for this issue, but I don’t think the additional sync-leaderboard.js modifications and storing ranking inside the leaderboard snapshot JSON files are really necessary here.

I’d suggest simplifying this by keeping the fetch-student-info.js changes, directly returning apiData.ranking || 0, removing the part where it tries to fetch the rank from historical data when the API fails, and removing the additional sync-leaderboard.js changes and ranking persistence from leaderboard JSON generation entirely.

That would keep the implementation much cleaner and more aligned with the original issue scope.

@Yashaswini-K-P Yashaswini-K-P requested a review from jagdish-15 June 8, 2026 16:53
Comment thread scripts/fetch-student-info.js Outdated
Comment thread scripts/sync-leaderboard.js
@Yashaswini-K-P Yashaswini-K-P requested a review from jagdish-15 June 9, 2026 04:59
@jagdish-15 jagdish-15 added type:feature New feature or request level:beginner Indicates the difficulty gssoc:approved labels Jun 9, 2026
@jagdish-15 jagdish-15 merged commit 42823b0 into codepvg:main Jun 9, 2026
1 check passed
@Yashaswini-K-P Yashaswini-K-P deleted the feature/add-global-ranking branch June 9, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved level:beginner Indicates the difficulty type:feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Global Ranking to /api/student/:username Response

2 participants