Skip to content

Commit 0bf3fa2

Browse files
committed
fix: critical onlhy
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent a62f998 commit 0bf3fa2

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

services/apps/packages_worker/src/bin/maven-repo-url-backfill.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const DEFAULT_BATCH_SIZE = 5000
2323

2424
const main = async () => {
2525
const dryRun = process.argv.includes('--dry-run')
26+
const criticalOnly = process.argv.includes('--critical-only')
2627
const rawBatchSize = process.env.MAVEN_REPO_URL_BACKFILL_BATCH_SIZE
2728
const parsedBatchSize = rawBatchSize === undefined ? DEFAULT_BATCH_SIZE : Number(rawBatchSize)
2829
if (!Number.isInteger(parsedBatchSize) || parsedBatchSize <= 0) {
@@ -35,7 +36,7 @@ const main = async () => {
3536
const batchSize = parsedBatchSize
3637

3738
log.info(
38-
{ dryRun, batchSize },
39+
{ dryRun, criticalOnly, batchSize },
3940
'maven repo-url backfill starting (recompute normalizeScmUrl from declared_repository_url, no POM fetch)...',
4041
)
4142

@@ -46,6 +47,7 @@ const main = async () => {
4647
const totals = await backfillMavenRepositoryUrls(qx, {
4748
batchSize,
4849
dryRun,
50+
criticalOnly,
4951
isShuttingDown: () => shuttingDown,
5052
})
5153

services/apps/packages_worker/src/maven/backfillRepositoryUrl.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ export type RepoUrlBackfillTotals = {
4242
*/
4343
export async function backfillMavenRepositoryUrls(
4444
qx: QueryExecutor,
45-
options: { batchSize: number; dryRun: boolean; isShuttingDown: () => boolean },
45+
options: {
46+
batchSize: number
47+
dryRun: boolean
48+
criticalOnly: boolean
49+
isShuttingDown: () => boolean
50+
},
4651
): Promise<RepoUrlBackfillTotals> {
47-
const { batchSize, dryRun, isShuttingDown } = options
52+
const { batchSize, dryRun, criticalOnly, isShuttingDown } = options
4853
const totals: RepoUrlBackfillTotals = {
4954
scanned: 0,
5055
filled: 0,
@@ -62,7 +67,11 @@ export async function backfillMavenRepositoryUrls(
6267
break
6368
}
6469

65-
const rows = await listMavenPackagesForRepoUrlRecompute(qx, { afterId, limit: batchSize })
70+
const rows = await listMavenPackagesForRepoUrlRecompute(qx, {
71+
afterId,
72+
limit: batchSize,
73+
criticalOnly,
74+
})
6675
if (rows.length === 0) break
6776

6877
const updates: { id: number; repositoryUrl: string | null }[] = []
@@ -105,7 +114,10 @@ export async function backfillMavenRepositoryUrls(
105114
}
106115

107116
afterId = rows[rows.length - 1].id
108-
log.info({ afterId, changes: updates.length, dryRun, ...totals }, 'Backfill progress')
117+
log.info(
118+
{ afterId, changes: updates.length, dryRun, criticalOnly, ...totals },
119+
'Backfill progress',
120+
)
109121
}
110122

111123
return totals

services/libs/data-access-layer/src/osspckgs/packages.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,13 @@ export type MavenRepoUrlRow = {
131131
* canonical). Rows with neither are skipped — there is nothing to recompute.
132132
* Used by the repository_url backfill to re-run the normalizer over stored data
133133
* without re-fetching POMs from the registry.
134+
*
135+
* `criticalOnly` restricts the scan to is_critical rows (index-backed by the
136+
* partial index on is_critical) — used for a fast, consumer-facing first pass.
134137
*/
135138
export async function listMavenPackagesForRepoUrlRecompute(
136139
qx: QueryExecutor,
137-
options: { afterId: number; limit: number },
140+
options: { afterId: number; limit: number; criticalOnly?: boolean },
138141
): Promise<MavenRepoUrlRow[]> {
139142
return qx.select(
140143
`
@@ -144,6 +147,7 @@ export async function listMavenPackagesForRepoUrlRecompute(
144147
repository_url AS "repositoryUrl"
145148
FROM packages
146149
WHERE ecosystem = 'maven'
150+
${options.criticalOnly ? 'AND is_critical' : ''}
147151
AND id > $(afterId)
148152
AND (declared_repository_url IS NOT NULL OR repository_url IS NOT NULL)
149153
ORDER BY id ASC

0 commit comments

Comments
 (0)