2
0

(setVariable) Add Transcription system var (#1507)

Closes #1484
This commit is contained in:
Baptiste Arnaud
2024-05-15 14:24:55 +02:00
committed by GitHub
parent ec7ff8d9ca
commit 40f21203b5
102 changed files with 2911 additions and 986 deletions

View File

@@ -4,24 +4,33 @@ import { Answer, Result } from '@typebot.io/schemas'
type Props = {
id: string
}
export const findResult = ({ id }: Props) =>
prisma.result.findFirst({
where: { id, isArchived: { not: true } },
select: {
id: true,
variables: true,
hasStarted: true,
answers: {
select: {
content: true,
blockId: true,
variableId: true,
export const findResult = async ({ id }: Props) => {
const { answers, answersV2, ...result } =
(await prisma.result.findFirst({
where: { id, isArchived: { not: true } },
select: {
id: true,
variables: true,
hasStarted: true,
answers: {
select: {
content: true,
blockId: true,
},
},
answersV2: {
select: {
content: true,
blockId: true,
},
},
},
},
}) as Promise<
| (Pick<Result, 'id' | 'variables' | 'hasStarted'> & {
answers: Pick<Answer, 'content' | 'blockId' | 'variableId'>[]
})
| null
>
})) ?? {}
if (!result) return null
return {
...result,
answers: (answersV2 ?? []).concat(answers ?? []),
} as Pick<Result, 'id' | 'variables' | 'hasStarted'> & {
answers: Pick<Answer, 'content' | 'blockId'>[]
}
}