Skip to content

Commit 937eb98

Browse files
ulemonsskwowet
authored andcommitted
feat: import manual maintainers (CM-1299) (#4292)
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org> Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent d104e6e commit 937eb98

8 files changed

Lines changed: 985 additions & 11 deletions

File tree

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;

services/apps/packages_worker/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
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",
5456
"backfill:stewardship": "SERVICE=stewardship-backfill tsx src/bin/stewardship-backfill.ts",
5557
"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",
5658
"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)