Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE package_maintainers
ADD COLUMN IF NOT EXISTS ingestion_source text;
2 changes: 2 additions & 0 deletions services/apps/packages_worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"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",
"backfill:maven": "SERVICE=maven tsx src/bin/maven-backfill.ts",
"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",
"import:maven-maintainers": "SERVICE=maven tsx src/maven/scripts/importMaintainersFromCsv.ts",
"import:maven-maintainers:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=maven tsx src/maven/scripts/importMaintainersFromCsv.ts",
"backfill:stewardship": "SERVICE=stewardship-backfill tsx src/bin/stewardship-backfill.ts",
"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",
"monitor:osspckgs": "SERVICE=bq-dataset-ingest tsx src/scripts/monitorOsspckgs.ts",
Expand Down
56 changes: 56 additions & 0 deletions services/apps/packages_worker/src/maven/scripts/csv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export function parseCsv(content: string): Record<string, string>[] {
const rows: string[][] = []
let cur = ''
let inQuote = false
let row: string[] = []

for (let i = 0; i < content.length; i++) {
const ch = content[i]
const next = content[i + 1]

if (inQuote) {
if (ch === '"' && next === '"') {
cur += '"'
i++
} else if (ch === '"') {
inQuote = false
} else {
cur += ch
}
} else {
if (ch === '"') {
inQuote = true
} else if (ch === ',') {
row.push(cur)
cur = ''
} else if (ch === '\r' && next === '\n') {
row.push(cur)
cur = ''
rows.push(row)
row = []
i++
} else if (ch === '\n') {
row.push(cur)
cur = ''
rows.push(row)
row = []
} else {
cur += ch
}
}
}
if (cur || row.length) {
row.push(cur)
rows.push(row)
}

if (rows.length === 0) return []
const headers = rows[0]
return rows.slice(1).map((r) => {
const obj: Record<string, string> = {}
headers.forEach((h, i) => {
obj[h.trim()] = (r[i] ?? '').trim()
})
return obj
})
}
Loading
Loading