Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/scripts/find-eligible-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* - fewer than 5 currently open PRs
* - more than 2 merged PRs
* - merge rate (merged / closed) > 50%
* - "low priority" PRs < 50%
*
* Usage:
* GITHUB_TOKEN=xxxx node find-eligible-contributors.js <owner> <repo>
Expand Down Expand Up @@ -95,6 +96,8 @@ async function fetchCollaborators(owner, repo, token) {
* open: number,
* closed: number,
* merged: number,
* total: number,
* lowPriority: number,
* mostRecentCreatedAt: Date
* }>
*/
Expand All @@ -110,11 +113,18 @@ function aggregateUserStats(pullRequests) {
open: 0,
closed: 0,
merged: 0,
total: 0,
lowPriority: 0,
mostRecentCreatedAt: null,
});
}
const s = stats.get(login);

s.total += 1;
if (pr.labels?.some((label) => label.name === 'low priority')) {
s.lowPriority += 1;
}

if (pr.state === 'open') {
s.open += 1;
} else if (pr.state === 'closed') {
Expand All @@ -138,6 +148,7 @@ function aggregateUserStats(pullRequests) {
* - fewer than 5 currently open PRs
* - more than 2 merged PRs
* - merge rate (merged / closed) > 50%
* - "low priority" PRs < 50%
* - not a collaborator
* - has an open PR or at least one PR within the past 6 weeks
*/
Expand All @@ -152,6 +163,7 @@ function filterEligibleUsers(stats, collaboratorLogins) {
if (collaboratorLogins.has(login)) continue;
if (s.open == 0 && s.mostRecentCreatedAt < cutoff) continue;
if ((s.merged / s.closed) < 0.5) continue;
if ((s.lowPriority / s.total) > 0.5) continue;

eligible.push(login);
}
Expand Down
Loading