-
Notifications
You must be signed in to change notification settings - Fork 9
feat(PM-2177): modified schema to support vote tracking #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
08b0321
feat: modified schema to support vote tracking
hentrymartin 866b227
fix: updated upVote and downVote logic
hentrymartin 16418fc
fix: updated upVote and downVote logic
hentrymartin f24042d
fix: updated upVote and downVote logic
hentrymartin 2b5ecd5
fix: review comments
hentrymartin fbe4a61
fix: review comments
hentrymartin efc9371
fix: review comments
hentrymartin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
prisma/migrations/20251117152627_add_vote_tracking_to_ai_workflow_run_items/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| Warnings: | ||
| - You are about to drop the column `downVotes` on the `aiWorkflowRunItem` table. All the data in the column will be lost. | ||
| - You are about to drop the column `upVotes` on the `aiWorkflowRunItem` table. All the data in the column will be lost. | ||
| - You are about to drop the column `downVotes` on the `aiWorkflowRunItemComment` table. All the data in the column will be lost. | ||
| - You are about to drop the column `upVotes` on the `aiWorkflowRunItemComment` table. All the data in the column will be lost. | ||
| */ | ||
| -- CreateEnum | ||
| CREATE TYPE "VoteType" AS ENUM ('UPVOTE', 'DOWNVOTE'); | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "aiWorkflowRunItem" DROP COLUMN "downVotes", | ||
| DROP COLUMN "upVotes"; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "aiWorkflowRunItemComment" DROP COLUMN "downVotes", | ||
| DROP COLUMN "upVotes"; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "aiWorkflowRunItemVote" ( | ||
| "id" VARCHAR(14) NOT NULL DEFAULT nanoid(), | ||
| "workflowRunItemId" VARCHAR(14) NOT NULL, | ||
| "voteType" "VoteType" NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "createdBy" TEXT NOT NULL, | ||
|
|
||
| CONSTRAINT "aiWorkflowRunItemVote_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "aiWorkflowRunItemCommentVote" ( | ||
| "id" VARCHAR(14) NOT NULL DEFAULT nanoid(), | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "workflowRunItemCommentId" VARCHAR(14) NOT NULL, | ||
| "voteType" "VoteType" NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "createdBy" TEXT NOT NULL, | ||
|
|
||
| CONSTRAINT "aiWorkflowRunItemCommentVote_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "aiWorkflowRunItemVote_workflowRunItemId_idx" ON "aiWorkflowRunItemVote"("workflowRunItemId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "aiWorkflowRunItemVote_workflowRunItemId_createdBy_key" ON "aiWorkflowRunItemVote"("workflowRunItemId", "createdBy"); | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "aiWorkflowRunItemCommentVote_workflowRunItemCommentId_idx" ON "aiWorkflowRunItemCommentVote"("workflowRunItemCommentId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "aiWorkflowRunItemCommentVote_workflowRunItemCommentId_creat_key" ON "aiWorkflowRunItemCommentVote"("workflowRunItemCommentId", "createdBy"); | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "aiWorkflowRunItemVote" ADD CONSTRAINT "aiWorkflowRunItemVote_workflowRunItemId_fkey" FOREIGN KEY ("workflowRunItemId") REFERENCES "aiWorkflowRunItem"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "aiWorkflowRunItemCommentVote" ADD CONSTRAINT "aiWorkflowRunItemCommentVote_workflowRunItemCommentId_fkey" FOREIGN KEY ("workflowRunItemCommentId") REFERENCES "aiWorkflowRunItemComment"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -643,6 +643,37 @@ model llmModel { | |
| workflows aiWorkflow[] | ||
| } | ||
|
|
||
| model aiWorkflowRunItemVote { | ||
| id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| workflowRunItemId String @db.VarChar(14) | ||
| voteType VoteType | ||
| createdAt DateTime @default(now()) @db.Timestamp(3) | ||
| createdBy String @db.Text | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| item aiWorkflowRunItem @relation(fields: [workflowRunItemId], references: [id], onDelete: Cascade) | ||
|
|
||
| @@index([workflowRunItemId]) | ||
| @@unique([workflowRunItemId, createdBy]) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| model aiWorkflowRunItemCommentVote { | ||
| id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| workflowRunItemCommentId String @db.VarChar(14) | ||
| voteType VoteType | ||
| createdAt DateTime @default(now()) @db.Timestamp(3) | ||
| createdBy String @db.Text | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
|
|
||
| comment aiWorkflowRunItemComment @relation(fields: [workflowRunItemCommentId], references: [id], onDelete: Cascade) | ||
|
|
||
| @@index([workflowRunItemCommentId]) | ||
| @@unique([workflowRunItemCommentId, createdBy]) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| enum VoteType { | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| UPVOTE | ||
| DOWNVOTE | ||
| } | ||
|
|
||
| model aiWorkflow { | ||
| id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14) | ||
| name String @unique @db.VarChar | ||
|
|
@@ -690,24 +721,22 @@ model aiWorkflowRunItem { | |
| workflowRunId String @db.VarChar(14) | ||
| scorecardQuestionId String @db.VarChar(14) | ||
| content String @db.Text | ||
| upVotes Int @default(0) | ||
| downVotes Int @default(0) | ||
| questionScore Float? @db.DoublePrecision | ||
| createdAt DateTime @db.Timestamp(3) | ||
| createdBy String? @db.Text | ||
|
|
||
| run aiWorkflowRun @relation(fields: [workflowRunId], references: [id]) | ||
| question scorecardQuestion @relation(fields: [scorecardQuestionId], references: [id]) | ||
| comments aiWorkflowRunItemComment[] | ||
|
|
||
| votes aiWorkflowRunItemVote[] | ||
| } | ||
|
|
||
| model aiWorkflowRunItemComment { | ||
| id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14) | ||
| workflowRunItemId String @db.VarChar(14) | ||
| userId String @db.Text | ||
| content String @db.Text | ||
| upVotes Int @default(0) | ||
| downVotes Int @default(0) | ||
| parentId String? @db.VarChar(14) | ||
| createdAt DateTime @default(now()) @db.Timestamp(3) | ||
| createdBy String? @db.Text | ||
|
|
@@ -717,4 +746,6 @@ model aiWorkflowRunItemComment { | |
| item aiWorkflowRunItem @relation(fields: [workflowRunItemId], references: [id]) | ||
| parent aiWorkflowRunItemComment? @relation("CommentHierarchy", fields: [parentId], references: [id]) | ||
| replies aiWorkflowRunItemComment[] @relation("CommentHierarchy") | ||
|
|
||
| votes aiWorkflowRunItemCommentVote[] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.