Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/fetch-student-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,27 @@ async function fetchStudentHistory(username) {
console.log("Fetching history for:", username);

let history = [];
let ranking = null;
let missingFilesCount = 0;
const maxDays = 365;
const chunkSize = 100;

try {
const liveApiUrl = `https://leetcode-api-dun.vercel.app/${username}`;
const apiResponse = await fetch(liveApiUrl);
if (apiResponse.ok) {
const apiData = await apiResponse.json();
// Captures the live ranking directly from the endpoint payload
ranking = apiData.ranking || 0;
console.log(`Live ranking fetched for ${username}:`, ranking);
}
} catch (err) {
console.error(
"Failed to fetch live global ranking from API wrapper:",
err.message,
);
}

let done = false;

for (let chunkStart = 0; chunkStart < maxDays; chunkStart += chunkSize) {
Expand Down Expand Up @@ -82,6 +99,7 @@ async function fetchStudentHistory(username) {

return {
username,
ranking,
history,
};
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/sync-leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ async function computeRankChanges(currentSorted, filename) {
dailyData.splice(i--, 1);
continue;
}

dailyData[i].data.easySolved -= previousData[previousIndex].data.easySolved;
dailyData[i].data.mediumSolved -=
previousData[previousIndex].data.mediumSolved;
dailyData[i].data.hardSolved -= previousData[previousIndex].data.hardSolved;

dailyData[i].score =
dailyData[i].data.easySolved +
dailyData[i].data.mediumSolved * 3 +
Expand Down
Loading