Skip to content

Commit 670bedf

Browse files
committed
Fix Slack snippet showing info only for one repository
We need the snippet to show information about issues and PRs from all repositories in which we typically accept contributions.
1 parent be91fcc commit 670bedf

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

scripts/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ const PR_STATS_REPOS = [
9696
'ricecooker',
9797
];
9898

99+
// Repositories in which we accept open-source contributions
100+
const COMMUNITY_REPOS = [...PR_STATS_REPOS];
101+
99102
module.exports = {
100103
LE_BOT_USERNAME,
101104
SENTRY_BOT_USERNAME,
@@ -109,4 +112,5 @@ module.exports = {
109112
TEAMS_WITH_CLOSE_CONTRIBUTORS,
110113
HOLIDAY_MESSAGE,
111114
PR_STATS_REPOS,
115+
COMMUNITY_REPOS,
112116
};

scripts/contributor-issue-comment.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
ISSUE_LABEL_HELP_WANTED,
77
BOT_MESSAGE_ISSUE_NOT_OPEN,
88
BOT_MESSAGE_ALREADY_ASSIGNED,
9+
COMMUNITY_REPOS,
910
} = require('./constants');
1011
const {
1112
isCloseContributor,
@@ -159,8 +160,8 @@ module.exports = async ({ github, context, core }) => {
159160

160161
if (contactSupport) {
161162
const [assignedOpenIssues, openPRs] = await Promise.all([
162-
getIssues(commentAuthor, 'open', owner, repo, github, core),
163-
getPullRequests(commentAuthor, 'open', owner, repo, github, core),
163+
getIssues(commentAuthor, 'open', owner, COMMUNITY_REPOS, github, core),
164+
getPullRequests(commentAuthor, 'open', owner, COMMUNITY_REPOS, github, core),
164165
]);
165166
const authorActivity = formatAuthorActivity(assignedOpenIssues, openPRs);
166167
slackMessage += ` _${authorActivity}_`;

scripts/utils.js

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -190,38 +190,50 @@ async function hasLabel(name, owner, repo, issueNumber, github, core) {
190190
}
191191

192192
/**
193-
* Fetches issues assigned to a user.
193+
* Fetches issues assigned to an assignee in given repositories.
194194
*/
195-
async function getIssues(assignee, state, owner, repo, github, core) {
196-
try {
197-
const response = await github.rest.issues.listForRepo({
198-
owner,
199-
repo,
200-
assignee,
201-
state,
202-
});
203-
return response.data.filter(issue => !issue.pull_request);
204-
} catch (error) {
205-
core.warning(`Failed to fetch issues: ${error.message}`);
206-
return [];
195+
async function getIssues(assignee, state, owner, repos, github, core) {
196+
const allIssues = [];
197+
198+
for (const repo of repos) {
199+
try {
200+
const response = await github.rest.issues.listForRepo({
201+
owner,
202+
repo,
203+
assignee,
204+
state,
205+
});
206+
const issues = response.data.filter(issue => !issue.pull_request);
207+
allIssues.push(...issues);
208+
} catch (error) {
209+
core.warning(`Failed to fetch issues from ${repo}: ${error.message}`);
210+
}
207211
}
212+
213+
return allIssues;
208214
}
209215

210216
/**
211-
* Fetches pull requests for an author.
217+
* Fetches pull requests by an author in given repositories.
212218
*/
213-
async function getPullRequests(author, state, owner, repo, github, core) {
214-
try {
215-
const response = await github.rest.pulls.list({
216-
owner,
217-
repo,
218-
state,
219-
});
220-
return response.data.filter(pr => pr.user.login === author);
221-
} catch (error) {
222-
core.warning(`Failed to fetch pull requests: ${error.message}`);
223-
return [];
219+
async function getPullRequests(author, state, owner, repos, github, core) {
220+
const allPRs = [];
221+
222+
for (const repo of repos) {
223+
try {
224+
const response = await github.rest.pulls.list({
225+
owner,
226+
repo,
227+
state,
228+
});
229+
const prs = response.data.filter(pr => pr.user.login === author);
230+
allPRs.push(...prs);
231+
} catch (error) {
232+
core.warning(`Failed to fetch pull requests from ${repo}: ${error.message}`);
233+
}
224234
}
235+
236+
return allPRs;
225237
}
226238

227239
module.exports = {

0 commit comments

Comments
 (0)