Skip to content

Commit

Permalink
Update updateLeaderboard.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunhThanhDe authored Oct 29, 2024
1 parent cc82f3c commit 99e4183
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/updateLeaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ module.exports = async ({ github, context }) => {

recentPlaysRows.unshift(newEntry);


console.log("Current length of recentPlaysRows after sorting:", recentPlaysRows.length);
if (recentPlaysRows.length > 20) {
recentPlaysRows.pop();
ecentPlaysRows = recentPlaysRows.slice(0, 20);
}


Expand Down Expand Up @@ -97,7 +97,11 @@ module.exports = async ({ github, context }) => {
return dateB.localeCompare(dateA);
});

if (leaderboardRows.length > 20) leaderboardRows.pop();
console.log("Current length of leaderboardRows after sorting:", leaderboardRows.length);

if (leaderboardRows.length > 20) {
leaderboardRows = leaderboardRows.slice(0, 20); // Giữ lại 20 phần tử đầu tiên
}

const updatedLeaderboard = `<!-- Leaderboard -->\n| Score | Player | Message | Date |\n|-------|--------|---------|------|\n${leaderboardRows.join('\n')}\n<!-- /Leaderboard -->`;
readme = readme.replace(leaderboardSection[0], updatedLeaderboard);
Expand Down

0 comments on commit 99e4183

Please sign in to comment.