2
0

🗃️ Add createdAt to sort transcript answers

This commit is contained in:
Baptiste Arnaud
2024-05-22 15:44:49 +02:00
parent ab9e36f68d
commit 79ad1f63de
6 changed files with 34 additions and 17 deletions

View File

@ -261,12 +261,14 @@ const parseResultTranscriptProps = async (
select: {
blockId: true,
content: true,
createdAt: true,
},
},
answersV2: {
select: {
blockId: true,
content: true,
createdAt: true,
},
},
setVariableHistory: {
@ -281,7 +283,9 @@ const parseResultTranscriptProps = async (
})
if (!result) return
return {
answers: result.answersV2.concat(result.answers),
answers: result.answersV2
.concat(result.answers)
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime()),
setVariableHistory: (
result.setVariableHistory as SetVariableHistoryItem[]
).sort((a, b) => a.index - b.index),

View File

@ -320,11 +320,12 @@ model Answer {
}
model AnswerV2 {
id Int @id @default(autoincrement())
blockId String
content String @db.Text
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
blockId String
content String @db.Text
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([resultId])
@@index([blockId])

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "AnswerV2" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -300,11 +300,12 @@ model Answer {
}
model AnswerV2 {
id Int @id @default(autoincrement())
blockId String
content String
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
blockId String
content String
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([blockId])
}