@@ -69,7 +69,6 @@ const maxClose =
6969const sleepMs = requireNonNegativeInteger ( "sleep-ms" , values [ "sleep-ms" ] )
7070const printLimit = requireNonNegativeInteger ( "print-limit" , values [ "print-limit" ] )
7171const cutoff = subtractMonths ( new Date ( ) , ageMonths )
72- const teamAssociations = new Set ( [ "OWNER" , "MEMBER" , "COLLABORATOR" ] )
7372
7473const headers = {
7574 Authorization : `Bearer ${ token } ` ,
@@ -83,7 +82,6 @@ type PullRequest = {
8382 title : string
8483 url : string
8584 createdAt : string
86- authorAssociation : string
8785 reactionGroups : Array < {
8886 content : string
8987 users : {
@@ -147,25 +145,19 @@ async function main() {
147145 console . log ( `Threshold: fewer than ${ threshold } positive reactions` )
148146
149147 const prs = await fetchOpenPullRequests ( )
150- const scored = prs . map ( ( pr ) => ( { ...pr , positiveReactions : positiveReactionCount ( pr ) } ) )
151- const recentCount = scored . filter ( ( pr ) => new Date ( pr . createdAt ) >= cutoff ) . length
152- const teamCount = scored . filter ( ( pr ) => isTeamMember ( pr ) ) . length
153- const matching = scored . filter (
154- ( pr ) => ! isTeamMember ( pr ) && new Date ( pr . createdAt ) < cutoff && pr . positiveReactions < threshold ,
155- )
148+ const recentCount = prs . filter ( ( pr ) => new Date ( pr . createdAt ) >= cutoff ) . length
149+ const matching = prs
150+ . map ( ( pr ) => ( { ...pr , positiveReactions : positiveReactionCount ( pr ) } ) )
151+ . filter ( ( pr ) => new Date ( pr . createdAt ) < cutoff && pr . positiveReactions < threshold )
156152 const candidates = matching . filter ( ( pr ) => ! hasPriorCleanup ( pr ) )
157153 const selected = maxClose === undefined ? candidates : candidates . slice ( 0 , maxClose )
158154
159155 console . log ( `Fetched ${ prs . length } open PRs` )
160156 console . log ( `Matching cleanup criteria: ${ matching . length } ` )
161157 console . log ( `Skipped previously cleaned PRs: ${ matching . length - candidates . length } ` )
162- console . log ( `Team member PRs untouched: ${ teamCount } ` )
163158 console . log ( `Recent PRs untouched: ${ recentCount } ` )
164159 console . log (
165- `Older PRs with at least ${ threshold } positive reactions untouched: ${
166- scored . filter ( ( pr ) => ! isTeamMember ( pr ) && new Date ( pr . createdAt ) < cutoff && pr . positiveReactions >= threshold )
167- . length
168- } `,
160+ `Older PRs with at least ${ threshold } positive reactions untouched: ${ prs . length - matching . length - recentCount } ` ,
169161 )
170162
171163 if ( selected . length === 0 ) return
@@ -213,7 +205,6 @@ async function fetchOpenPullRequests() {
213205 title
214206 url
215207 createdAt
216- authorAssociation
217208 reactionGroups {
218209 content
219210 users {
@@ -344,10 +335,6 @@ function hasPriorCleanup(pr: PullRequest) {
344335 return pr . labels . nodes . some ( ( label ) => label . name === cleanupLabel )
345336}
346337
347- function isTeamMember ( pr : PullRequest ) {
348- return teamAssociations . has ( pr . authorAssociation )
349- }
350-
351338function requireRepo ( value : string | undefined ) {
352339 if ( ! value ) throw new Error ( "repo is required" )
353340 const [ owner , name ] = value . split ( "/" )
0 commit comments