skip duplicates when inserting calls and messages
This commit is contained in:
@ -15,6 +15,7 @@ const fetchCallsQueue = Queue<Payload>("api/queue/fetch-calls", async ({ organiz
|
||||
include: { organization: true },
|
||||
});
|
||||
if (!phoneNumber) {
|
||||
console.log("no phone number found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ const insertCallsQueue = Queue<Payload>("api/queue/insert-calls", async ({ calls
|
||||
}))
|
||||
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
||||
|
||||
await db.phoneCall.createMany({ data: phoneCalls });
|
||||
await db.phoneCall.createMany({ data: phoneCalls, skipDuplicates: true });
|
||||
});
|
||||
|
||||
export default insertCallsQueue;
|
||||
|
Reference in New Issue
Block a user