Skip to content

Commit 5d02fb0

Browse files
committed
cascade delete
1 parent 1f629e4 commit 5d02fb0

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

src/api/submission/submission.service.ts

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,45 +2310,49 @@ export class SubmissionService {
23102310
);
23112311
}
23122312

2313-
await this.prisma.$transaction(async (tx) => {
2314-
for (const run of runs) {
2315-
const runId = run.id;
2313+
await this.prisma.aiWorkflowRun.deleteMany({
2314+
where: { submissionId: id },
2315+
});
23162316

2317-
const items = await tx.aiWorkflowRunItem.findMany({
2318-
where: { workflowRunId: runId },
2319-
select: { id: true },
2320-
});
2317+
// await this.prisma.$transaction(async (tx) => {
2318+
// for (const run of runs) {
2319+
// const runId = run.id;
23212320

2322-
const itemIds = items.map((i) => i.id);
2321+
// const items = await tx.aiWorkflowRunItem.findMany({
2322+
// where: { workflowRunId: runId },
2323+
// select: { id: true },
2324+
// });
23232325

2324-
const comments = await tx.aiWorkflowRunItemComment.findMany({
2325-
where: { workflowRunItemId: { in: itemIds } },
2326-
select: { id: true },
2327-
});
2326+
// const itemIds = items.map((i) => i.id);
23282327

2329-
const commentIds = comments.map((c) => c.id);
2328+
// const comments = await tx.aiWorkflowRunItemComment.findMany({
2329+
// where: { workflowRunItemId: { in: itemIds } },
2330+
// select: { id: true },
2331+
// });
23302332

2331-
await tx.aiWorkflowRunItemVote.deleteMany({
2332-
where: { workflowRunItemId: { in: itemIds } },
2333-
});
2333+
// const commentIds = comments.map((c) => c.id);
23342334

2335-
await tx.aiWorkflowRunItemCommentVote.deleteMany({
2336-
where: { workflowRunItemCommentId: { in: commentIds } },
2337-
});
2335+
// await tx.aiWorkflowRunItemVote.deleteMany({
2336+
// where: { workflowRunItemId: { in: itemIds } },
2337+
// });
23382338

2339-
await tx.aiWorkflowRunItemComment.deleteMany({
2340-
where: { workflowRunItemId: { in: itemIds } },
2341-
});
2339+
// await tx.aiWorkflowRunItemCommentVote.deleteMany({
2340+
// where: { workflowRunItemCommentId: { in: commentIds } },
2341+
// });
23422342

2343-
await tx.aiWorkflowRunItem.deleteMany({
2344-
where: { workflowRunId: runId },
2345-
});
2343+
// await tx.aiWorkflowRunItemComment.deleteMany({
2344+
// where: { workflowRunItemId: { in: itemIds } },
2345+
// });
23462346

2347-
await tx.aiWorkflowRun.deleteMany({
2348-
where: { id: runId },
2349-
});
2350-
}
2351-
});
2347+
// await tx.aiWorkflowRunItem.deleteMany({
2348+
// where: { workflowRunId: runId },
2349+
// });
2350+
2351+
// await tx.aiWorkflowRun.deleteMany({
2352+
// where: { id: runId },
2353+
// });
2354+
// }
2355+
// });
23522356
}
23532357

23542358
await this.prisma.submission.delete({

0 commit comments

Comments
 (0)