Skip to content
Closed
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
2 changes: 1 addition & 1 deletion frontend/js/user/badges.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function loadBadges(data) {
ranks.overall.rank !== "--"
) {
const overallRank = parseInt(ranks.overall.rank, 10);
if (!isNaN(overallRank) && overallRank <= 10) {
if (!Number.isNaN(overallRank) && overallRank <= 10) {
earnedSet.add("TOP_BRASS");
}
}
Expand Down
29 changes: 1 addition & 28 deletions scripts/fetch-user-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,4 @@ async function fetchUserInfo(username) {

// 2. Fetch live profile ranking from the wrapper API
const livePromise = fetchWithTimeout(liveApiUrl).then(async (res) => {
if (res.ok) {
const apiData = await res.json();
ranking = apiData.ranking || 0;
contest = apiData.contest || null;
} else {
throw new Error(`LeetCode API wrapper returned status ${res.status}`);
}
});

// Wait for the live API task to complete
await livePromise;

// Ensure history is sorted chronologically
// Guard against a corrupted history file (e.g. non-array `history` field)
history = Array.isArray(history) ? history : [];
history.sort((a, b) => new Date(a.date) - new Date(b.date));

return {
username,
streak,
ranking,
leaderboardRanks,
contest,
history,
};
}

module.exports = fetchUserInfo;
.catch(err => console.error(err))
Loading