🚑 Fix answer upsert missing groupId
This commit is contained in:
@@ -193,16 +193,16 @@ const saveAnswer =
|
|||||||
(state: SessionState, block: InputBlock, itemId?: string) =>
|
(state: SessionState, block: InputBlock, itemId?: string) =>
|
||||||
async (reply: string): Promise<SessionState> => {
|
async (reply: string): Promise<SessionState> => {
|
||||||
const resultId = state.result?.id
|
const resultId = state.result?.id
|
||||||
const answer = {
|
const answer: Omit<Prisma.AnswerUncheckedCreateInput, 'resultId'> = {
|
||||||
resultId,
|
|
||||||
blockId: block.id,
|
blockId: block.id,
|
||||||
itemId,
|
itemId,
|
||||||
|
groupId: block.groupId,
|
||||||
content: reply,
|
content: reply,
|
||||||
variableId: block.options.variableId,
|
variableId: block.options.variableId,
|
||||||
storageUsed: 0,
|
storageUsed: 0,
|
||||||
}
|
}
|
||||||
if (state.result.answers.length === 0 && state.result.id)
|
if (state.result.answers.length === 0 && resultId)
|
||||||
await setResultAsStarted(state.result.id)
|
await setResultAsStarted(resultId)
|
||||||
|
|
||||||
const newSessionState = setNewAnswerInState(state)({
|
const newSessionState = setNewAnswerInState(state)({
|
||||||
blockId: block.id,
|
blockId: block.id,
|
||||||
@@ -221,9 +221,13 @@ const saveAnswer =
|
|||||||
blockId: block.id,
|
blockId: block.id,
|
||||||
groupId: block.groupId,
|
groupId: block.groupId,
|
||||||
},
|
},
|
||||||
|
itemId: answer.itemId,
|
||||||
|
},
|
||||||
|
create: { ...answer, resultId },
|
||||||
|
update: {
|
||||||
|
content: answer.content,
|
||||||
|
storageUsed: answer.storageUsed,
|
||||||
},
|
},
|
||||||
create: answer as Prisma.AnswerUncheckedCreateInput,
|
|
||||||
update: answer,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
previewFeatures = ["extendedWhereUnique"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
previewFeatures = ["extendedWhereUnique"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|||||||
Reference in New Issue
Block a user