⚡ Replace updates with updateManys when possible
Easy performance win to avoid triggering SELECT query after an UPDATE
This commit is contained in:
@ -144,7 +144,7 @@ const sendAlertIfLimitReached = async (
|
||||
chatsLimit,
|
||||
url: `https://app.typebot.io/typebots?workspaceId=${workspace.id}`,
|
||||
})
|
||||
await prisma.workspace.update({
|
||||
await prisma.workspace.updateMany({
|
||||
where: { id: workspace.id },
|
||||
data: { chatsLimitFirstEmailSentAt: new Date() },
|
||||
})
|
||||
@ -168,7 +168,7 @@ const sendAlertIfLimitReached = async (
|
||||
chatsLimit,
|
||||
url: `https://app.typebot.io/typebots?workspaceId=${workspace.id}`,
|
||||
})
|
||||
await prisma.workspace.update({
|
||||
await prisma.workspace.updateMany({
|
||||
where: { id: workspace.id },
|
||||
data: { chatsLimitSecondEmailSentAt: new Date() },
|
||||
})
|
||||
@ -179,7 +179,7 @@ const sendAlertIfLimitReached = async (
|
||||
|
||||
if (totalChatsUsed > chatsLimit * 3 && workspace.plan === Plan.FREE) {
|
||||
console.log(`Automatically quarantine workspace ${workspace.id}...`)
|
||||
await prisma.workspace.update({
|
||||
await prisma.workspace.updateMany({
|
||||
where: { id: workspace.id },
|
||||
data: { isQuarantined: true },
|
||||
})
|
||||
|
Reference in New Issue
Block a user