From 16e4f39dede1bd51af48707b613a057170433e09 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Tue, 4 Jun 2024 15:15:06 -0500 Subject: [PATCH] Batch subsessions and reduce batch sizes for seeding database --- db/seed.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/seed.ts b/db/seed.ts index b6b71e0..65b13dd 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -24,7 +24,7 @@ import seasonIdArray from "./distinct-season-ids.json"; import subsessions from "./subsessions-output.json"; function batchInserts(array: Array): Array> { - const size = 200; + const size = 100; const count = array.length; const batches = Math.ceil(count / size); return Array(batches) @@ -168,6 +168,11 @@ export default async function seed() { ); if (subsessionCount !== allSubsessions.length) { await db.delete(Subsession); + await Promise.all( + batchInserts(allSubsessions).map((batch) => + db.insert(Subsession).values(batch) + ) + ); await db.insert(Subsession).values(allSubsessions); } console.log("Seeding Subsession Practice Results...");