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
58 changes: 57 additions & 1 deletion .github/workflows/bot-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,29 @@ jobs:
}

function buildAccountSummaryTable(sortedAccounts, limit) {
const baseRepoURL = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
function linkCount(count, url) {
if (!count) return '0';
return `[${count}](${url})`;
}

const rows = [];
const capped = sortedAccounts.slice(0, limit);
for (const [login, data] of capped) {
const encodedLogin = encodeURIComponent(login);
const openIssues = (data.issues || []).filter(i => i.state === 'open').length;
const closedIssues = (data.issues || []).filter(i => i.state === 'closed').length;
const openPRs = (data.prs || []).filter(p => p.state === 'open').length;
const closedPRs = (data.prs || []).filter(p => p.state === 'closed').length;
const comments = (data.comments || []).length;

rows.push(`| @${login} | ${data.daysOld}d | ${openIssues} | ${closedIssues} | ${openPRs} | ${closedPRs} | ${comments} |`);
const openIssuesLink = linkCount(openIssues, `${baseRepoURL}/issues?q=is%3Aissue+is%3Aopen+author%3A${encodedLogin}`);
const closedIssuesLink = linkCount(closedIssues, `${baseRepoURL}/issues?q=is%3Aissue+is%3Aclosed+author%3A${encodedLogin}`);
const openPRsLink = linkCount(openPRs, `${baseRepoURL}/pulls?q=is%3Apr+is%3Aopen+author%3A${encodedLogin}`);
const closedPRsLink = linkCount(closedPRs, `${baseRepoURL}/pulls?q=is%3Apr+is%3Aclosed+author%3A${encodedLogin}`);
const commentsLink = linkCount(comments, `${baseRepoURL}/issues?q=commenter%3A${encodedLogin}`);

Comment on lines +51 to +56
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table counts issues/PRs/comments from data.*, which are filtered to created_at >= cutoff elsewhere in this script, but the new links here don’t include any time filter. Clicking the linked counts can therefore show more results than the count displayed. Consider passing the cutoff (or at least the cutoff date) into buildAccountSummaryTable and adding a created:>=... qualifier (or otherwise making the linked query match the same window as the counts).

Suggested change
const openIssuesLink = linkCount(openIssues, `${baseRepoURL}/issues?q=is%3Aissue+is%3Aopen+author%3A${encodedLogin}`);
const closedIssuesLink = linkCount(closedIssues, `${baseRepoURL}/issues?q=is%3Aissue+is%3Aclosed+author%3A${encodedLogin}`);
const openPRsLink = linkCount(openPRs, `${baseRepoURL}/pulls?q=is%3Apr+is%3Aopen+author%3A${encodedLogin}`);
const closedPRsLink = linkCount(closedPRs, `${baseRepoURL}/pulls?q=is%3Apr+is%3Aclosed+author%3A${encodedLogin}`);
const commentsLink = linkCount(comments, `${baseRepoURL}/issues?q=commenter%3A${encodedLogin}`);
const cutoffIso = cutoff.toISOString();
const cutoffQuery = `+created%3A%3E%3D${encodeURIComponent(cutoffIso)}`;
const openIssuesLink = linkCount(
openIssues,
`${baseRepoURL}/issues?q=is%3Aissue+is%3Aopen+author%3A${encodedLogin}${cutoffQuery}`,
);
const closedIssuesLink = linkCount(
closedIssues,
`${baseRepoURL}/issues?q=is%3Aissue+is%3Aclosed+author%3A${encodedLogin}${cutoffQuery}`,
);
const openPRsLink = linkCount(
openPRs,
`${baseRepoURL}/pulls?q=is%3Apr+is%3Aopen+author%3A${encodedLogin}${cutoffQuery}`,
);
const closedPRsLink = linkCount(
closedPRs,
`${baseRepoURL}/pulls?q=is%3Apr+is%3Aclosed+author%3A${encodedLogin}${cutoffQuery}`,
);
const commentsLink = linkCount(
comments,
`${baseRepoURL}/issues?q=commenter%3A${encodedLogin}${cutoffQuery}`,
);

Copilot uses AI. Check for mistakes.
rows.push(`| @${login} | ${data.daysOld}d | ${openIssuesLink} | ${closedIssuesLink} | ${openPRsLink} | ${closedPRsLink} | ${commentsLink} |`);
}

const header = [
Expand Down Expand Up @@ -146,6 +159,27 @@ jobs:
reviewComments.push(...data);
}

// Review submissions (e.g., "LGTM" reviews) are NOT included in listReviewComments.
const reviews = [];
if (github.paginate?.iterator) {
for await (const response of github.paginate.iterator(github.rest.pulls.listReviews, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
})) {
reviews.push(...response.data);
}
} else {
const { data } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
});
reviews.push(...data);
}

for (const comment of [...issueComments, ...reviewComments]) {
if (new Date(comment.created_at) < cutoff) continue;
const login = comment.user?.login;
Expand All @@ -162,6 +196,28 @@ jobs:
timestamp: comment.created_at,
});
}

for (const review of reviews) {
const submittedAt = review.submitted_at || review.submittedAt;
if (!submittedAt) continue;
if (new Date(submittedAt) < cutoff) continue;

const login = review.user?.login;
if (!login) continue;

await ensureUserCreatedDate(login);

if (!commentsByUser.has(login)) {
commentsByUser.set(login, []);
}

const reviewURL = review.html_url || `${pr.html_url}#pullrequestreview-${review.id}`;
commentsByUser.get(login).push({
pr: pr.number,
url: reviewURL,
timestamp: submittedAt,
});
}
}

// Also consider recent issue creators (not just PR comments).
Expand Down