Skip to content

Commit 8423b2a

Browse files
authored
Merge pull request #45 from cffbots/36-contributors
2 parents d3c3fbc + 07e0b28 commit 8423b2a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

query.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ const hasRecentCommits = async (url) => {
8282
return elapsed <= inactivity_threshold
8383
}
8484

85+
86+
const hasSufficientContributors = async (url) => {
87+
const [ owner, repo, ...unuseds ] = url.slice("https://github.com/".length).split('/');
88+
89+
const contributors = await octokit.rest.repos.listContributors({
90+
owner,
91+
repo,
92+
});
93+
94+
let ncontributors = 0
95+
for (const c of contributors.data) {
96+
if (c.contributions >= ncontributions_minimum) {
97+
ncontributors++;
98+
}
99+
}
100+
101+
return ncontributors >= ncontributors_minimum;
102+
}
103+
85104
const filterAsync = async (arr, asyncCallback) => {
86105
const promises = arr.map(asyncCallback);
87106
const results = await Promise.all(promises);
@@ -101,6 +120,8 @@ const urls_rsd = loadFromJsonfile('./urls.json');
101120
const nworkflows_minimum = 1;
102121
const npull_requests_minimum = 5;
103122
const inactivity_threshold = 12 * 30 * 24 * 60 * 60 * 1000 // X months in milliseconds -> X months * 30 days/month * 24 hours/day * 60 min/hour * 60 sec/min * 1000
123+
const ncontributors_minimum = 3;
124+
const ncontributions_minimum = 5;
104125

105126
const octokit = new Octokit({auth: process.env.GITHUB_TOKEN});
106127

@@ -110,6 +131,7 @@ urls = await filterAsync(urls, includeUsesPullRequests);
110131
urls = await filterAsync(urls, hasMultipleChangesToCitationcff);
111132
urls = await filterAsync(urls, includeUsesWorkflows);
112133
urls = await filterAsync(urls, hasRecentCommits);
134+
urls = await filterAsync(urls, hasSufficientContributors);
113135
urls.forEach(url => console.log(url))
114136

115137

0 commit comments

Comments
 (0)