mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
fix(issues): address document review comments
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
ab41fdbaee
commit
eb0a74384e
4 changed files with 55 additions and 15 deletions
|
|
@ -5,11 +5,13 @@ import {
|
|||
assets,
|
||||
companies,
|
||||
companyMemberships,
|
||||
documents,
|
||||
goals,
|
||||
heartbeatRuns,
|
||||
issueAttachments,
|
||||
issueLabels,
|
||||
issueComments,
|
||||
issueDocuments,
|
||||
issueReadStates,
|
||||
issues,
|
||||
labels,
|
||||
|
|
@ -790,6 +792,10 @@ export function issueService(db: Db) {
|
|||
.select({ assetId: issueAttachments.assetId })
|
||||
.from(issueAttachments)
|
||||
.where(eq(issueAttachments.issueId, id));
|
||||
const issueDocumentIds = await tx
|
||||
.select({ documentId: issueDocuments.documentId })
|
||||
.from(issueDocuments)
|
||||
.where(eq(issueDocuments.issueId, id));
|
||||
|
||||
const removedIssue = await tx
|
||||
.delete(issues)
|
||||
|
|
@ -803,6 +809,12 @@ export function issueService(db: Db) {
|
|||
.where(inArray(assets.id, attachmentAssetIds.map((row) => row.assetId)));
|
||||
}
|
||||
|
||||
if (removedIssue && issueDocumentIds.length > 0) {
|
||||
await tx
|
||||
.delete(documents)
|
||||
.where(inArray(documents.id, issueDocumentIds.map((row) => row.documentId)));
|
||||
}
|
||||
|
||||
if (!removedIssue) return null;
|
||||
const [enriched] = await withIssueLabels(tx, [removedIssue]);
|
||||
return enriched;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue