Skip to content

Commit

Permalink
Update leaderboard.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dscarlett-chwy authored Oct 17, 2024
1 parent be439ad commit c2b6002
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/leaderboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
const size = labels.find(label => POINT_VALUES[label.name.toLowerCase()]);
return size ? POINT_VALUES[size.name.toLowerCase()] : POINT_VALUES.small;
};
const fetchRecentPRs = async (repo) => {
try {
console.log(`Fetching recent PRs for ${repo}`);
Expand All @@ -63,30 +62,35 @@ jobs:
let allPRs = [];
let page = 1;
let hasMorePRs = true;
while (true) {
while (hasMorePRs) {
const { data: prs } = await github.rest.pulls.list({
owner: repoOwner,
repo: repoName,
state: 'closed',
sort: 'updated',
direction: 'desc',
per_page: 1000,
per_page: 100, // GitHub's maximum allowed value
page: page
});
if (prs.length === 0) break;
allPRs = allPRs.concat(prs);
const oldestPRDate = new Date(prs[prs.length - 1].merged_at);
if (oldestPRDate < new Date(startDate)) break;
page++;
if (prs.length < 100) {
hasMorePRs = false;
} else {
const oldestPRDate = new Date(prs[prs.length - 1].updated_at);
if (oldestPRDate < new Date(startDate)) {
hasMorePRs = false;
} else {
page++;
}
}
}
console.log(`Fetched ${allPRs.length} PRs for ${repo}`);
const hacktoberfestPRs = allPRs.filter(pr => {
const isMerged = !!pr.merged_at;
const mergedAt = new Date(pr.merged_at);
Expand All @@ -100,14 +104,13 @@ jobs:
prNumber: pr.number,
prTitle: pr.title,
}));
return hacktoberfestPRs;
} catch (error) {
console.error(`Error fetching PRs for ${repo}: ${error.message}`);
return [];
}
};
const generateLeaderboard = async () => {
try {
const allPRs = await Promise.all(REPOS.map(fetchRecentPRs));
Expand Down

0 comments on commit c2b6002

Please sign in to comment.