skip duplicates when inserting calls and messages
This commit is contained in:
parent
306febe4d1
commit
f628addd80
@ -35,7 +35,7 @@ const insertMessagesQueue = Queue<Payload>(
|
||||
}))
|
||||
.sort((a, b) => a.sentAt.getTime() - b.sentAt.getTime());
|
||||
|
||||
await db.message.createMany({ data: sms });
|
||||
await db.message.createMany({ data: sms, skipDuplicates: true });
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user