diff --git a/scripts/contributors/collect.mjs b/scripts/contributors/collect.mjs index 4af9978a..d5628620 100644 --- a/scripts/contributors/collect.mjs +++ b/scripts/contributors/collect.mjs @@ -91,7 +91,7 @@ export async function fetchCommitRange(client, organization, fromDate, toDate) { /** * @param {GraphqlClient} client - * @param {{ organization: string; kind: "pr" | "issue"; qualifier: "updated" | "created"; fromDate: string; toDate: string; document: string }} options + * @param {{ organization: string; kind: "pr" | "issue"; qualifier: "updated" | "created" | "merged"; fromDate: string; toDate: string; document: string }} options * @returns {Promise} */ export async function fetchGraphqlSearchRange(client, options) { @@ -230,12 +230,20 @@ export async function collectGitHubActivity( ) { const fromDate = toDateKey(period.from); const toDate = toDateKey(period.to); - const [commits, pullRequests, issues] = await Promise.all([ + const [commits, prsByCreated, prsByMerged, issues] = await Promise.all([ fetchCommitRange(client, organization, fromDate, toDate), fetchGraphqlSearchRange(client, { organization, kind: "pr", - qualifier: "updated", + qualifier: "created", + fromDate, + toDate, + document: PULL_REQUEST_SEARCH, + }), + fetchGraphqlSearchRange(client, { + organization, + kind: "pr", + qualifier: "merged", fromDate, toDate, document: PULL_REQUEST_SEARCH, @@ -250,6 +258,11 @@ export async function collectGitHubActivity( }), ]); + const prById = new Map( + [...prsByCreated, ...prsByMerged].map((pr) => [pr.id, pr]), + ); + const pullRequests = [...prById.values()]; + const pullRequestsWithReviews = await mapWithConcurrency( pullRequests, REVIEW_CONCURRENCY,