Delete unused objects (#7823)
Fixes #7113 --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -2,10 +2,9 @@ import { WorkspaceQueryHookInstance } from 'src/engine/api/graphql/workspace-que
|
||||
import { DeleteOneResolverArgs } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
|
||||
|
||||
import { WorkspaceQueryHook } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/decorators/workspace-query-hook.decorator';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { CommentWorkspaceEntity } from 'src/modules/activity/standard-objects/comment.workspace-entity';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
import { AuthContext } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
|
||||
@WorkspaceQueryHook(`workspaceMember.deleteOne`)
|
||||
export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
@ -24,21 +23,12 @@ export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
'attachment',
|
||||
);
|
||||
|
||||
const commentRepository =
|
||||
await this.twentyORMManager.getRepository<CommentWorkspaceEntity>(
|
||||
'comment',
|
||||
);
|
||||
|
||||
const authorId = payload.id;
|
||||
|
||||
await attachmentRepository.delete({
|
||||
authorId,
|
||||
});
|
||||
|
||||
await commentRepository.delete({
|
||||
authorId,
|
||||
});
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,8 +27,6 @@ import {
|
||||
FieldTypeAndNameMetadata,
|
||||
getTsVectorColumnExpressionFromFields,
|
||||
} from 'src/engine/workspace-manager/workspace-sync-metadata/utils/get-ts-vector-column-expression.util';
|
||||
import { ActivityWorkspaceEntity } from 'src/modules/activity/standard-objects/activity.workspace-entity';
|
||||
import { CommentWorkspaceEntity } from 'src/modules/activity/standard-objects/comment.workspace-entity';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
import { BlocklistWorkspaceEntity } from 'src/modules/blocklist/standard-objects/blocklist.workspace-entity';
|
||||
import { CalendarEventParticipantWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-event-participant.workspace-entity';
|
||||
@ -142,30 +140,6 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
userId: string;
|
||||
|
||||
// Relations
|
||||
@WorkspaceRelation({
|
||||
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.authoredActivities,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Authored activities',
|
||||
description: 'Activities created by the workspace member',
|
||||
icon: 'IconCheckbox',
|
||||
inverseSideTarget: () => ActivityWorkspaceEntity,
|
||||
inverseSideFieldKey: 'author',
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
})
|
||||
authoredActivities: Relation<ActivityWorkspaceEntity[]>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.assignedActivities,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Assigned activities',
|
||||
description: 'Activities assigned to the workspace member',
|
||||
icon: 'IconCheckbox',
|
||||
inverseSideTarget: () => ActivityWorkspaceEntity,
|
||||
inverseSideFieldKey: 'assignee',
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
})
|
||||
assignedActivities: Relation<ActivityWorkspaceEntity[]>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.assignedTasks,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
@ -227,18 +201,6 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
})
|
||||
authoredAttachments: Relation<AttachmentWorkspaceEntity[]>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.authoredComments,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Authored comments',
|
||||
description: 'Authored comments',
|
||||
icon: 'IconComment',
|
||||
inverseSideTarget: () => CommentWorkspaceEntity,
|
||||
inverseSideFieldKey: 'author',
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
})
|
||||
authoredComments: Relation<CommentWorkspaceEntity[]>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.connectedAccounts,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
|
||||
Reference in New Issue
Block a user