Skip to content

Commit 18f79ef

Browse files
committed
Merge branch 'fix/osspckgs-monitor' into feat/add-rubygems-ingest-CM-1296
2 parents 6311438 + d9b3d38 commit 18f79ef

24 files changed

Lines changed: 3174 additions & 43 deletions

backend/src/database/repositories/memberRepository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ class MemberRepository {
244244

245245
const subprojectIds = await getSegmentSubprojectIds(qx, currentSegments)
246246

247+
if (subprojectIds.length === 0) {
248+
return
249+
}
250+
247251
await seq.query(bulkDeleteMemberSegments, {
248252
replacements: {
249253
memberIds,

backend/src/database/repositories/organizationRepository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ class OrganizationRepository {
192192
const qx = SequelizeRepository.getQueryExecutor(options)
193193
const subprojectIds = await getSegmentSubprojectIds(qx, currentSegments)
194194

195+
if (subprojectIds.length === 0) {
196+
return
197+
}
198+
195199
await seq.query(bulkDeleteOrganizationSegments, {
196200
replacements: {
197201
organizationIds,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE package_maintainers
2+
ADD COLUMN IF NOT EXISTS ingestion_source text;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Sonatype popularity signal (first delivery: Maven P0, top 500 components).
2+
-- Sonatype could not provide raw Maven download counts, so instead they deliver a
3+
-- popularity score derived from their SCA telemetry: normalized 0-100 per ecosystem,
4+
-- tiered P0-P3. Stored in dedicated columns (not JSONB) because score/rank/tier are
5+
-- queried independently. Only sonatype_popularity_score feeds rank_packages(); rank and
6+
-- tier are kept for display/audit. No index on first pass (dataset is small, 500-2k rows).
7+
ALTER TABLE packages
8+
ADD COLUMN IF NOT EXISTS sonatype_popularity_score numeric, -- 0-100, normalized per ecosystem; consumed by rank_packages()
9+
ADD COLUMN IF NOT EXISTS sonatype_rank int, -- rank within the Sonatype list; display/audit only
10+
ADD COLUMN IF NOT EXISTS sonatype_tier text, -- 'P0' | 'P1' | 'P2' | 'P3'
11+
ADD COLUMN IF NOT EXISTS sonatype_snapshot_at timestamptz, -- timestamp of the Sonatype snapshot the row came from
12+
ADD COLUMN IF NOT EXISTS sonatype_updated_at timestamptz; -- our last upsert of the sonatype_* fields

services/apps/git_integration/src/crowdgit/services/clone/clone_service.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
retry_on_clone_error = retry(
4949
retry=retry_if_exception_type(RETRYABLE_CLONE_ERRORS),
50-
stop=stop_after_attempt(6),
50+
stop=stop_after_attempt(3),
5151
wait=wait_exponential(multiplier=5, min=5, max=120),
5252
reraise=True,
5353
)
@@ -190,9 +190,14 @@ async def _perform_minimal_clone(self, path: str, remote: str) -> None:
190190
Perform minimal clone of depth=1
191191
"""
192192
self.logger.info("Initializing minimal clone")
193-
await run_shell_command(
194-
["git", "clone", "--depth=1", "--no-tags", "--single-branch", remote, "."], cwd=path
195-
)
193+
base_cmd = ["git", "clone", "--depth=1", "--no-tags", "--single-branch"]
194+
try:
195+
await run_shell_command([*base_cmd, f"{remote}.git", "."], cwd=path)
196+
except Exception:
197+
self.logger.warning(
198+
f"Clone with .git suffix failed, falling back to bare URL: {remote}"
199+
)
200+
await run_shell_command([*base_cmd, remote, "."], cwd=path)
196201
self.logger.info("Minimal clone initialized successfully")
197202

198203
async def _get_repo_size_mb(self, repo_path: str) -> float:
@@ -377,9 +382,14 @@ async def _cleanup_working_directory(self, repo_path: str) -> None:
377382
async def _perform_full_clone(self, repo_path: str, remote: str):
378383
"""Perform full repository clone"""
379384
self.logger.info(f"Performing full clone for repo {remote}...")
380-
await run_shell_command(
381-
["git", "clone", "--no-tags", "--single-branch", remote, "."], cwd=repo_path
382-
)
385+
base_cmd = ["git", "clone", "--no-tags", "--single-branch"]
386+
try:
387+
await run_shell_command([*base_cmd, f"{remote}.git", "."], cwd=repo_path)
388+
except Exception:
389+
self.logger.warning(
390+
f"Clone with .git suffix failed, falling back to bare URL: {remote}"
391+
)
392+
await run_shell_command([*base_cmd, remote, "."], cwd=repo_path)
383393
self.logger.info(f"Successfully completed full clone of repository: {remote}")
384394

385395
async def has_default_branch_changed(self, remote: str, saved_branch: str | None) -> bool:

services/apps/packages_worker/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
"dev:nuget-worker:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && CROWD_TEMPORAL_TASKQUEUE=nuget-worker SERVICE=nuget-worker LOG_LEVEL=trace nodemon --watch src --watch ../../libs --ext ts --exec tsx --inspect=0.0.0.0:9242 src/bin/nuget-worker.ts",
5252
"backfill:maven": "SERVICE=maven tsx src/bin/maven-backfill.ts",
5353
"backfill:maven:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=maven LOG_LEVEL=info tsx src/bin/maven-backfill.ts",
54+
"import:maven-maintainers": "SERVICE=maven tsx src/maven/scripts/importMaintainersFromCsv.ts",
55+
"import:maven-maintainers:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=maven tsx src/maven/scripts/importMaintainersFromCsv.ts",
56+
"import:sonatype-popularity": "SERVICE=maven tsx src/maven/scripts/importSonatypePopularityFromCsv.ts",
57+
"import:sonatype-popularity:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=maven tsx src/maven/scripts/importSonatypePopularityFromCsv.ts",
5458
"backfill:stewardship": "SERVICE=stewardship-backfill tsx src/bin/stewardship-backfill.ts",
5559
"backfill:stewardship:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=stewardship-backfill LOG_LEVEL=info tsx src/bin/stewardship-backfill.ts",
5660
"monitor:osspckgs": "SERVICE=bq-dataset-ingest tsx src/scripts/monitorOsspckgs.ts",
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export function parseCsv(content: string): Record<string, string>[] {
2+
const rows: string[][] = []
3+
let cur = ''
4+
let inQuote = false
5+
let row: string[] = []
6+
7+
for (let i = 0; i < content.length; i++) {
8+
const ch = content[i]
9+
const next = content[i + 1]
10+
11+
if (inQuote) {
12+
if (ch === '"' && next === '"') {
13+
cur += '"'
14+
i++
15+
} else if (ch === '"') {
16+
inQuote = false
17+
} else {
18+
cur += ch
19+
}
20+
} else {
21+
if (ch === '"') {
22+
inQuote = true
23+
} else if (ch === ',') {
24+
row.push(cur)
25+
cur = ''
26+
} else if (ch === '\r' && next === '\n') {
27+
row.push(cur)
28+
cur = ''
29+
rows.push(row)
30+
row = []
31+
i++
32+
} else if (ch === '\n') {
33+
row.push(cur)
34+
cur = ''
35+
rows.push(row)
36+
row = []
37+
} else {
38+
cur += ch
39+
}
40+
}
41+
}
42+
if (cur || row.length) {
43+
row.push(cur)
44+
rows.push(row)
45+
}
46+
47+
if (rows.length === 0) return []
48+
const headers = rows[0]
49+
return rows.slice(1).map((r) => {
50+
const obj: Record<string, string> = {}
51+
headers.forEach((h, i) => {
52+
obj[h.trim()] = (r[i] ?? '').trim()
53+
})
54+
return obj
55+
})
56+
}

0 commit comments

Comments
 (0)