⚡ (analytics) Improve analytics graph accuracy
This commit is contained in:
@@ -274,6 +274,7 @@ model Answer {
|
||||
createdAt DateTime @default(now()) @updatedAt
|
||||
resultId String
|
||||
blockId String
|
||||
itemId String?
|
||||
groupId String
|
||||
variableId String?
|
||||
content String @db.Text
|
||||
@@ -281,7 +282,7 @@ model Answer {
|
||||
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([resultId, blockId, groupId])
|
||||
@@index([groupId])
|
||||
@@index([blockId, itemId])
|
||||
@@index([storageUsed])
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
-- DropIndex
|
||||
DROP INDEX IF EXISTS "Answer_groupId_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX IF EXISTS "Result_typebotId_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE
|
||||
"Answer"
|
||||
ADD
|
||||
COLUMN "itemId" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Answer_blockId_itemId_idx" ON "Answer"("blockId", "itemId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Answer_storageUsed_idx" ON "Answer"("storageUsed");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Result_typebotId_hasStarted_createdAt_idx" ON "Result"("typebotId", "hasStarted", "createdAt" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Result_typebotId_isCompleted_idx" ON "Result"("typebotId", "isCompleted");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Typebot_isArchived_createdAt_idx" ON "Typebot"("isArchived", "createdAt" DESC);
|
||||
@@ -255,6 +255,7 @@ model Answer {
|
||||
createdAt DateTime @default(now()) @updatedAt
|
||||
resultId String
|
||||
blockId String
|
||||
itemId String?
|
||||
groupId String
|
||||
variableId String?
|
||||
content String
|
||||
@@ -262,7 +263,7 @@ model Answer {
|
||||
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([resultId, blockId, groupId])
|
||||
@@index([groupId])
|
||||
@@index([blockId, itemId])
|
||||
@@index([storageUsed])
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { executePrismaCommand } from './executeCommand'
|
||||
|
||||
executePrismaCommand('prisma db push --skip-generate')
|
||||
executePrismaCommand('prisma db push --skip-generate --accept-data-loss')
|
||||
|
||||
9
packages/schemas/features/analytics.ts
Normal file
9
packages/schemas/features/analytics.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const totalAnswersInBlock = z.object({
|
||||
blockId: z.string(),
|
||||
itemId: z.string().optional(),
|
||||
total: z.number(),
|
||||
})
|
||||
|
||||
export type TotalAnswersInBlock = z.infer<typeof totalAnswersInBlock>
|
||||
@@ -5,6 +5,7 @@ export const answerSchema = z.object({
|
||||
createdAt: z.date(),
|
||||
resultId: z.string(),
|
||||
blockId: z.string(),
|
||||
itemId: z.string().nullable(),
|
||||
groupId: z.string(),
|
||||
variableId: z.string().nullable(),
|
||||
content: z.string(),
|
||||
@@ -22,6 +23,7 @@ export const answerInputSchema = answerSchema
|
||||
z.object({
|
||||
variableId: z.string().nullish(),
|
||||
storageUsed: z.number().nullish(),
|
||||
itemId: z.string().nullish(),
|
||||
})
|
||||
) satisfies z.ZodType<Prisma.AnswerUncheckedUpdateInput>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user