add import messages/calls ui feedback

This commit is contained in:
m5r
2021-09-25 07:07:40 +08:00
parent 8f0a6f7060
commit 2f45e1d9a8
14 changed files with 153 additions and 16 deletions

View File

@ -34,6 +34,22 @@ 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, skipDuplicates: true });
const processingState = await db.processingPhoneNumber.findFirst({ where: { organizationId, phoneNumberId } });
if (!processingState) {
return;
}
if (processingState.hasFetchedMessages) {
await db.processingPhoneNumber.delete({
where: { organizationId_phoneNumberId: { organizationId, phoneNumberId } },
});
} else {
await db.processingPhoneNumber.update({
where: { organizationId_phoneNumberId: { organizationId, phoneNumberId } },
data: { hasFetchedCalls: true },
});
}
});
export default insertCallsQueue;