@@ -914,8 +914,6 @@ export interface FetchIssuesAndPRsResult {
914914interface LightSearchResult {
915915 issues : Issue [ ] ;
916916 pullRequests : PullRequest [ ] ;
917- /** GraphQL node IDs for phase 2 backfill */
918- prNodeIds : string [ ] ;
919917 errors : ApiError [ ] ;
920918}
921919
@@ -1058,6 +1056,32 @@ async function executeLightCombinedQuery(
10581056 }
10591057}
10601058
1059+ /** Cap-check, notify, and assemble a LightSearchResult from working collections. */
1060+ function finalizeSearchResult (
1061+ issues : Issue [ ] ,
1062+ prMap : Map < number , PullRequest > ,
1063+ errors : ApiError [ ] ,
1064+ issueSource : string ,
1065+ prSource : string ,
1066+ issueLabel : string ,
1067+ prLabel : string ,
1068+ ) : LightSearchResult {
1069+ if ( issues . length >= SEARCH_RESULT_CAP ) {
1070+ console . warn ( `[api] ${ issueLabel } capped at ${ SEARCH_RESULT_CAP } ` ) ;
1071+ pushNotification ( issueSource , `${ issueLabel } capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1072+ issues . splice ( SEARCH_RESULT_CAP ) ;
1073+ }
1074+
1075+ if ( prMap . size >= SEARCH_RESULT_CAP ) {
1076+ console . warn ( `[api] ${ prLabel } capped at ${ SEARCH_RESULT_CAP } ` ) ;
1077+ pushNotification ( prSource , `${ prLabel } capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1078+ }
1079+
1080+ const pullRequests = [ ...prMap . values ( ) ] ;
1081+ if ( pullRequests . length >= SEARCH_RESULT_CAP ) pullRequests . splice ( SEARCH_RESULT_CAP ) ;
1082+ return { issues, pullRequests, errors } ;
1083+ }
1084+
10611085/**
10621086 * Phase 1: light combined search. Fetches issues fully and PRs with minimal fields.
10631087 * Returns light PRs (enriched: false) and their GraphQL node IDs for phase 2 backfill.
@@ -1071,7 +1095,6 @@ async function graphqlLightCombinedSearch(
10711095 return {
10721096 issues : [ ] ,
10731097 pullRequests : [ ] ,
1074- prNodeIds : [ ] ,
10751098 errors : [ { repo : "search" , statusCode : null , message : "Invalid userLogin" , retryable : false } ] ,
10761099 } ;
10771100 }
@@ -1101,22 +1124,11 @@ async function graphqlLightCombinedSearch(
11011124 }
11021125 } ) ) ;
11031126
1104- if ( issues . length >= SEARCH_RESULT_CAP ) {
1105- console . warn ( `[api] Issue search results capped at ${ SEARCH_RESULT_CAP } ` ) ;
1106- pushNotification ( "search/issues" , `Issue search results capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1107- issues . splice ( SEARCH_RESULT_CAP ) ;
1108- }
1109-
1110- if ( prMap . size >= SEARCH_RESULT_CAP ) {
1111- console . warn ( `[api] PR search results capped at ${ SEARCH_RESULT_CAP } ` ) ;
1112- pushNotification ( "search/prs" , `PR search results capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1113- }
1114-
1115- const pullRequests = [ ...prMap . values ( ) ] ;
1116- if ( pullRequests . length >= SEARCH_RESULT_CAP ) pullRequests . splice ( SEARCH_RESULT_CAP ) ;
1117- const prNodeIds = pullRequests . map ( ( pr ) => nodeIdMap . get ( pr . id ) ) . filter ( ( id ) : id is string => id != null ) ;
1118-
1119- return { issues, pullRequests, prNodeIds, errors } ;
1127+ return finalizeSearchResult (
1128+ issues , prMap , errors ,
1129+ "search/issues" , "search/prs" ,
1130+ "Issue search results" , "PR search results" ,
1131+ ) ;
11201132}
11211133
11221134/**
@@ -1129,7 +1141,7 @@ async function graphqlUnfilteredSearch(
11291141 octokit : GitHubOctokit ,
11301142 repos : RepoRef [ ]
11311143) : Promise < LightSearchResult > {
1132- if ( repos . length === 0 ) return { issues : [ ] , pullRequests : [ ] , prNodeIds : [ ] , errors : [ ] } ;
1144+ if ( repos . length === 0 ) return { issues : [ ] , pullRequests : [ ] , errors : [ ] } ;
11331145
11341146 const chunks = chunkArray ( repos , SEARCH_REPO_BATCH_SIZE ) ;
11351147 const issueSeen = new Set < number > ( ) ;
@@ -1207,21 +1219,11 @@ async function graphqlUnfilteredSearch(
12071219 }
12081220 } ) ) ;
12091221
1210- if ( issues . length >= SEARCH_RESULT_CAP ) {
1211- console . warn ( `[api] Unfiltered issue results capped at ${ SEARCH_RESULT_CAP } ` ) ;
1212- pushNotification ( "search/unfiltered-issues" , `Monitored repo issue results capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1213- issues . splice ( SEARCH_RESULT_CAP ) ;
1214- }
1215-
1216- if ( prMap . size >= SEARCH_RESULT_CAP ) {
1217- console . warn ( `[api] Unfiltered PR results capped at ${ SEARCH_RESULT_CAP } ` ) ;
1218- pushNotification ( "search/unfiltered-prs" , `Monitored repo PR results capped at ${ SEARCH_RESULT_CAP . toLocaleString ( "en-US" ) } — some items are hidden` , "warning" ) ;
1219- }
1220-
1221- const pullRequests = [ ...prMap . values ( ) ] ;
1222- if ( pullRequests . length >= SEARCH_RESULT_CAP ) pullRequests . splice ( SEARCH_RESULT_CAP ) ;
1223- const prNodeIds = pullRequests . map ( ( pr ) => nodeIdMap . get ( pr . id ) ) . filter ( ( id ) : id is string => id != null ) ;
1224- return { issues, pullRequests, prNodeIds, errors } ;
1222+ return finalizeSearchResult (
1223+ issues , prMap , errors ,
1224+ "search/unfiltered-issues" , "search/unfiltered-prs" ,
1225+ "Monitored repo issue results" , "Monitored repo PR results" ,
1226+ ) ;
12251227}
12261228
12271229// ── Two-phase: heavy backfill ─────────────────────────────────────────────────
@@ -1356,7 +1358,6 @@ function mergeEnrichment(
13561358 * Merges tracked user search results into the main issue/PR maps.
13571359 * Items already present get the tracked user's login appended to surfacedBy.
13581360 * New items are added with surfacedBy: [trackedLogin].
1359- * Returns a union of all prNodeIds for backfill.
13601361 */
13611362function mergeTrackedUserResults (
13621363 issueMap : Map < number , Issue > ,
@@ -1475,7 +1476,7 @@ export async function fetchIssuesAndPullRequests(
14751476 // Unfiltered search for monitored repos — runs in parallel with tracked searches
14761477 const unfilteredPromise = monitoredReposList . length > 0
14771478 ? graphqlUnfilteredSearch ( octokit , monitoredReposList )
1478- : Promise . resolve ( { issues : [ ] , pullRequests : [ ] , prNodeIds : [ ] , errors : [ ] } as LightSearchResult ) ;
1479+ : Promise . resolve ( { issues : [ ] , pullRequests : [ ] , errors : [ ] } as LightSearchResult ) ;
14791480
14801481 const [ mainBackfill , trackedResults , unfilteredResult ] = await Promise . all ( [
14811482 mainBackfillPromise ,
@@ -2210,7 +2211,7 @@ export async function validateGitHubUser(
22102211 login : raw . login . toLowerCase ( ) ,
22112212 avatarUrl,
22122213 name : raw . name ?? null ,
2213- type : raw . type === "Bot" ? "bot" as const : "user" as const ,
2214+ type : raw . type === "Bot" ? "bot" : "user" ,
22142215 } ;
22152216}
22162217
0 commit comments