-
Notifications
You must be signed in to change notification settings - Fork 312
chore: enhance bot report summary #15175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,10 +60,27 @@ jobs: | |||||||||||
| const highRiskAccounts = new Map(); | ||||||||||||
| const commentsByUser = new Map(); | ||||||||||||
| const userCreatedDates = new Map(); | ||||||||||||
| const accountsSeen = new Set(); | ||||||||||||
| let userLookupFailures = 0; | ||||||||||||
|
|
||||||||||||
| async function ensureUserCreatedDate(login) { | ||||||||||||
| if (!login) return; | ||||||||||||
| accountsSeen.add(login); | ||||||||||||
| if (userCreatedDates.has(login)) return; | ||||||||||||
| try { | ||||||||||||
| const { data: userInfo } = await github.rest.users.getByUsername({ username: login }); | ||||||||||||
| userCreatedDates.set(login, new Date(userInfo.created_at)); | ||||||||||||
| } catch (e) { | ||||||||||||
| userLookupFailures += 1; | ||||||||||||
| userCreatedDates.set(login, null); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| for (const pr of prs.slice(0, MAX_PR)) { | ||||||||||||
| if (new Date(pr.updated_at) < cutoff) continue; | ||||||||||||
|
|
||||||||||||
| await ensureUserCreatedDate(pr.user?.login); | ||||||||||||
|
|
||||||||||||
| const issueComments = []; | ||||||||||||
| if (github.paginate?.iterator) { | ||||||||||||
| for await (const response of github.paginate.iterator(github.rest.issues.listComments, { | ||||||||||||
|
|
@@ -109,14 +126,7 @@ jobs: | |||||||||||
| const login = comment.user?.login; | ||||||||||||
| if (!login) continue; | ||||||||||||
|
|
||||||||||||
| if (!userCreatedDates.has(login)) { | ||||||||||||
| try { | ||||||||||||
| const { data: userInfo } = await github.rest.users.getByUsername({ username: login }); | ||||||||||||
| userCreatedDates.set(login, new Date(userInfo.created_at)); | ||||||||||||
| } catch (e) { | ||||||||||||
| userCreatedDates.set(login, null); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| await ensureUserCreatedDate(login); | ||||||||||||
|
|
||||||||||||
| if (!commentsByUser.has(login)) { | ||||||||||||
| commentsByUser.set(login, []); | ||||||||||||
|
|
@@ -129,6 +139,24 @@ jobs: | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Also consider recent issue creators (not just PR comments). | ||||||||||||
| // This helps catch new accounts that only opened issues/PRs (even if already closed). | ||||||||||||
| try { | ||||||||||||
| const { data: recentIssues } = await github.rest.issues.listForRepo({ | ||||||||||||
| owner: context.repo.owner, | ||||||||||||
| repo: context.repo.repo, | ||||||||||||
| state: 'all', | ||||||||||||
| since: cutoff.toISOString(), | ||||||||||||
| per_page: 100, | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| for (const issue of recentIssues) { | ||||||||||||
| await ensureUserCreatedDate(issue.user?.login); | ||||||||||||
|
||||||||||||
| await ensureUserCreatedDate(issue.user?.login); | |
| // github.rest.issues.listForRepo returns both issues and PRs; skip PRs here | |
| if (!issue.pull_request && issue.user?.login) { | |
| await ensureUserCreatedDate(issue.user.login); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new issue listing code doesn't use pagination like the PR listing does (lines 36-58). With
per_page: 100, this will only check the first 100 items. In active repositories with more than 100 issues/PRs in the last 6 hours, newer accounts that only created issues beyond the first 100 would be missed.Consider using pagination similar to the PR listing pattern to ensure all recent issues are checked.