Feature/add global ranking#120
Conversation
|
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
left a comment
There was a problem hiding this comment.
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.
Removed ranking data from leaderboard calculations.
| if (ranking === null || ranking === 0) { | ||
| ranking = user.ranking || 0; | ||
| } |
There was a problem hiding this comment.
| if (ranking === null || ranking === 0) { | |
| ranking = user.ranking || 0; | |
| } |
| @@ -1,5 +1,3 @@ | |||
| "use strict"; | |||
|
|
|||
| const axios = require("axios"); | |||
There was a problem hiding this comment.
| const axios = require("axios"); | |
| "use strict"; | |
| const axios = require("axios"); |
I think you accidentally removed this while resolving the conflicts. Please always check the final diffs provided by GitHub after resolving merge conflicts to ensure no unrelated changes were accidentally removed in the process.
Description
This PR extends the
/api/student/:usernameendpoint 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
fetchStudentHistoryto initially hit theleetcode-api-dun.vercel.appwrapper to capture the live, un-mutatedrankinginteger on-demand.rankingparameter to0or retrieve it sequentially from historical repositories if the upstream wrapper times out or fails.rankingkey directly alongsideusernameandhistorydata to align with frontend consumption criteria.Type of Change
Testing
Checklist
Screenshots / Screen Recording