fix: insertion freeproVentilationLines par lots de 50 pour eviter limite MySQL
This commit is contained in:
10
server/db.ts
10
server/db.ts
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user