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 9ef7336 commit 8099124
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/updateLeaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ module.exports = async ({ github, context }) => {
let recentPlaysContent = recentPlaysSection[0];
recentPlaysContent = recentPlaysContent.replace(/<!-- \/Recent Plays -->/, `${newEntry}<!-- \/Recent Plays -->`);

const recentPlaysRows = recentPlaysContent.split('\n').filter(row => row.startsWith('|') && !row.includes('Score | Player | Message | Date'));
const recentPlaysRows = recentPlaysContent
.split('\n')
.filter(row => row.startsWith('|') && !row.includes('Score | Player | Message | Date') && !row.includes('|-------|--------|---------|------|'));

if (recentPlaysRows.length > 20) recentPlaysRows.pop();

Expand All @@ -64,7 +66,9 @@ module.exports = async ({ github, context }) => {
let leaderboardContent = leaderboardSection[0];
leaderboardContent = leaderboardContent.replace(/<!-- \/Leaderboard -->/, `${newEntry}<!-- \/Leaderboard -->`);

const leaderboardRows = leaderboardContent.split('\n').filter(row => row.startsWith('|') && !row.includes('Score | Player | Message | Date'));
const leaderboardRows = leaderboardContent
.split('\n')
.filter(row => row.startsWith('|') && !row.includes('Score | Player | Message | Date') && !row.includes('|-------|--------|---------|------|'));

leaderboardRows.sort((a, b) => {
const scoreA = a.match(/^\| (\d+) \|/);
Expand Down

0 comments on commit 8099124

Please sign in to comment.