@ -8,6 +8,7 @@ type Props = {
|
||||
hasStarted: boolean
|
||||
isCompleted: boolean
|
||||
}
|
||||
|
||||
export const createResultIfNotExist = async ({
|
||||
resultId,
|
||||
typebot,
|
||||
|
@ -10,6 +10,7 @@ export const findPublicTypebot = ({ publicId }: Props) =>
|
||||
select: {
|
||||
version: true,
|
||||
groups: true,
|
||||
events: true,
|
||||
edges: true,
|
||||
settings: true,
|
||||
theme: true,
|
||||
|
@ -12,6 +12,7 @@ export const findTypebot = ({ id, userId }: Props) =>
|
||||
version: true,
|
||||
id: true,
|
||||
groups: true,
|
||||
events: true,
|
||||
edges: true,
|
||||
settings: true,
|
||||
theme: true,
|
||||
|
8
packages/bot-engine/queries/saveVisitedEdges.ts
Normal file
8
packages/bot-engine/queries/saveVisitedEdges.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { VisitedEdge } from '@typebot.io/prisma'
|
||||
|
||||
export const saveVisitedEdges = (visitedEdges: VisitedEdge[]) =>
|
||||
prisma.visitedEdge.createMany({
|
||||
data: visitedEdges,
|
||||
skipDuplicates: true,
|
||||
})
|
@ -4,18 +4,16 @@ import { InputBlock, SessionState } from '@typebot.io/schemas'
|
||||
|
||||
type Props = {
|
||||
answer: Omit<Prisma.AnswerUncheckedCreateInput, 'resultId'>
|
||||
block: InputBlock
|
||||
reply: string
|
||||
itemId?: string
|
||||
state: SessionState
|
||||
}
|
||||
export const upsertAnswer = async ({ answer, block, state }: Props) => {
|
||||
export const upsertAnswer = async ({ answer, state }: Props) => {
|
||||
const resultId = state.typebotsQueue[0].resultId
|
||||
if (!resultId) return
|
||||
const where = {
|
||||
resultId,
|
||||
blockId: block.id,
|
||||
groupId: block.groupId,
|
||||
blockId: answer.blockId,
|
||||
groupId: answer.groupId,
|
||||
}
|
||||
const existingAnswer = await prisma.answer.findUnique({
|
||||
where: {
|
||||
@ -28,7 +26,6 @@ export const upsertAnswer = async ({ answer, block, state }: Props) => {
|
||||
where,
|
||||
data: {
|
||||
content: answer.content,
|
||||
itemId: answer.itemId,
|
||||
},
|
||||
})
|
||||
return prisma.answer.createMany({
|
||||
|
Reference in New Issue
Block a user