Kuehlung gefixt
This commit is contained in:
39
src/testing/ausweise-fix-rechnungsid.ts
Normal file
39
src/testing/ausweise-fix-rechnungsid.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import moment from "moment";
|
||||
import { Enums, prisma } from "#lib/server/prisma.js";
|
||||
import * as fs from "fs";
|
||||
import { fileURLToPath } from "url";
|
||||
import { hashPassword } from "#lib/password.js";
|
||||
import Papa from "papaparse";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { tryCatch } from "#lib/tryCatch.js";
|
||||
import { createBrotliDecompress } from "zlib";
|
||||
|
||||
const path = fileURLToPath(new URL("./ausweise.csv.br", import.meta.url)); // .br for Brotli file
|
||||
|
||||
if (!fs.existsSync(path)) {
|
||||
throw new Error(`${path} existiert nicht.`);
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
const brotliStream = fs.createReadStream(path).pipe(createBrotliDecompress());
|
||||
|
||||
Papa.parse(brotliStream, {
|
||||
header: true,
|
||||
async complete(results, file) {
|
||||
for (const dataset of results.data as any) {
|
||||
const existing = await prisma.verbrauchsausweisWohnen.findFirst({
|
||||
where: {
|
||||
alte_ausweis_id: parseInt(dataset.id)
|
||||
}
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(dataset.id);
|
||||
// do something with dataset...
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user