@@ -72,7 +72,7 @@ async function fetchProjects(yamlUrl: string): Promise<ParsedProject[]> {
7272
7373 return Object . entries ( data ) . map ( ( [ project , info ] ) => ( {
7474 project,
75- repos : Object . values ( info . deliverables ?? { } ) . flatMap ( ( d ) => d . repos ?? [ ] ) ,
75+ repos : Object . values ( info ? .deliverables ?? { } ) . flatMap ( ( d ) => d . repos ?? [ ] ) ,
7676 } ) )
7777}
7878
@@ -145,7 +145,16 @@ const job: IJobDefinition = {
145145 let skipped = 0
146146
147147 // ------------------------------------------------------------------
148- // 4. Upsert one repository group per YAML project
148+ // 4. Bulk-fetch all repo URLs that exist in the DB (single round-trip)
149+ // ------------------------------------------------------------------
150+ const allCandidateUrls = projects . flatMap ( ( { repos } ) =>
151+ repos . map ( ( r ) => `${ source . repoUrlBase } ${ r } ` ) ,
152+ )
153+ const foundRepos = await getRepositoriesByUrl ( qx , allCandidateUrls )
154+ const foundUrlSet = new Set ( foundRepos . map ( ( r ) => r . url ) )
155+
156+ // ------------------------------------------------------------------
157+ // 5. Upsert one repository group per YAML project
149158 // ------------------------------------------------------------------
150159 for ( const { project, repos } of projects ) {
151160 if ( repos . length === 0 ) {
@@ -156,10 +165,7 @@ const job: IJobDefinition = {
156165
157166 const slug = toSlug ( project )
158167 const candidateUrls = repos . map ( ( r ) => `${ source . repoUrlBase } ${ r } ` )
159-
160- // Only include repos that actually exist in public.repositories
161- const foundRepos = await getRepositoriesByUrl ( qx , candidateUrls )
162- const foundUrls = foundRepos . map ( ( r ) => r . url )
168+ const foundUrls = candidateUrls . filter ( ( u ) => foundUrlSet . has ( u ) )
163169
164170 if ( foundUrls . length === 0 ) {
165171 ctx . log . debug (
@@ -169,7 +175,7 @@ const job: IJobDefinition = {
169175 continue
170176 }
171177
172- const missing = candidateUrls . filter ( ( u ) => ! foundUrls . includes ( u ) )
178+ const missing = candidateUrls . filter ( ( u ) => ! foundUrlSet . has ( u ) )
173179 if ( missing . length > 0 ) {
174180 ctx . log . warn (
175181 `'${ project } ': ${ missing . length } /${ candidateUrls . length } repos not found in DB` +
0 commit comments