Skip to content

Commit

Permalink
Chunking Call messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SunburntRock89 committed May 16, 2023
1 parent ea7eb66 commit a6f55e9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conversionScript/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,11 @@ const moveCalls = async() => {

console.info("[Call Messages] Pushing to DB...");
try {
const messagesRes = await prisma.callMessages.createMany({ data: callMessagesToInsert });
console.info(`[Call Messages] Successfully pushed ${messagesRes.count} records to DB.`);
for (let i = 0; i < callMessagesToInsert.length; i += 1000) {
const records = callMessagesToInsert.slice(i, i + 1000);
await prisma.callMessages.createMany({ data: records });
}
console.log("[Archived Calls] Successfully pushed all records to DB.");
} catch (e: unknown) {
await writeFile("callMessageError.json", (e as object).toString());
console.log(e);
Expand Down

0 comments on commit a6f55e9

Please sign in to comment.