fix: insertion freeproVentilationLines par lots de 50 pour eviter limite MySQL

This commit is contained in:
Manus
2026-06-05 08:26:31 -04:00
parent 7f56fa7045
commit ce6760a2ea
4 changed files with 45 additions and 4 deletions

View File

@@ -966,9 +966,13 @@ export async function createFreeproImport(
const result = await db.insert(freeproImports).values(data);
const importId = (result as unknown as { insertId: number }).insertId;
if (lines.length > 0) {
await db.insert(freeproVentilationLines).values(
lines.map((l) => ({ ...l, importId }))
);
const mappedLines = lines.map((l) => ({ ...l, importId }));
// Insérer par lots de 50 pour éviter les limites de paramètres MySQL
const BATCH_SIZE = 50;
for (let i = 0; i < mappedLines.length; i += BATCH_SIZE) {
const batch = mappedLines.slice(i, i + BATCH_SIZE);
await db.insert(freeproVentilationLines).values(batch);
}
}
return importId;
}