concurrency x2

This commit is contained in:
Cat /dev/Nulo 2024-09-07 16:43:50 -03:00
parent 076abab943
commit d3befb157b

View file

@ -126,6 +126,7 @@ async function importSucursales(
} }
async function importDataset(dir: string) { async function importDataset(dir: string) {
console.log(dir);
const date = basename(dir).match(/(\d{4}-\d{2}-\d{2})/)![1]; const date = basename(dir).match(/(\d{4}-\d{2}-\d{2})/)![1];
// TODO: parsear "Ultima actualizacion" al final del CSV y insertarlo en la tabla datasets // TODO: parsear "Ultima actualizacion" al final del CSV y insertarlo en la tabla datasets
@ -246,13 +247,12 @@ async function importDataset(dir: string) {
} }
} }
const pQueue = new PQueue({ concurrency: 4 }); const pQueue = new PQueue({ concurrency: 2 });
try { try {
const glob = new Glob("**/productos.csv"); const glob = new Glob("**/productos.csv");
for await (const file of glob.scan(process.argv[2])) { for await (const file of glob.scan(process.argv[2])) {
const dir = join(process.argv[2], dirname(file)); const dir = join(process.argv[2], dirname(file));
console.log(dir);
pQueue.add(() => importDataset(dir)); pQueue.add(() => importDataset(dir));
} }
} finally { } finally {