Skip to content

Commit 5ea4c91

Browse files
authored
Merge branch 'main' into validcff-filter
2 parents e395b05 + 8423b2a commit 5ea4c91

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
@@ -116,6 +116,25 @@ const hasRecentCommits = async (url) => {
116116
return elapsed <= inactivity_threshold
117117
}
118118

119+
120+
const hasSufficientContributors = async (url) => {
121+
const [ owner, repo, ...unuseds ] = url.slice("https://github.com/".length).split('/');
122+
123+
const contributors = await octokit.rest.repos.listContributors({
124+
owner,
125+
repo,
126+
});
127+
128+
let ncontributors = 0
129+
for (const c of contributors.data) {
130+
if (c.contributions >= ncontributions_minimum) {
131+
ncontributors++;
132+
}
133+
}
134+
135+
return ncontributors >= ncontributors_minimum;
136+
}
137+
119138
const filterAsync = async (arr, asyncCallback) => {
120139
const promises = arr.map(asyncCallback);
121140
const results = await Promise.all(promises);
@@ -135,6 +154,8 @@ const urls_rsd = loadFromJsonfile('./urls.json');
135154
const nworkflows_minimum = 1;
136155
const npull_requests_minimum = 5;
137156
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
157+
const ncontributors_minimum = 3;
158+
const ncontributions_minimum = 5;
138159

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

@@ -145,6 +166,7 @@ urls = await filterAsync(urls, hasMultipleChangesToCitationcff);
145166
urls = await filterAsync(urls, includeUsesWorkflows);
146167
urls = await filterAsync(urls, hasRecentCommits);
147168
urls = await filterAsync(urls, includeHasValidcff);
169+
urls = await filterAsync(urls, hasSufficientContributors);
148170
urls.forEach(url => console.log(url))
149171

150172

0 commit comments

Comments
 (0)