Delete unused objects (#7823)

Fixes #7113

---------

Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
Félix Malfait
2024-10-30 13:35:43 +01:00
committed by GitHub
parent 57d9b8e8b4
commit 50c912d57f
45 changed files with 422 additions and 1094 deletions

View File

@ -5,7 +5,6 @@ export type Attachment = {
type: AttachmentType;
companyId: string;
personId: string;
activityId: string;
authorId: string;
createdAt: string;
__typename: string;

View File

@ -18,7 +18,6 @@ const mockActivityTarget = {
updatedAt: '2021-08-03T19:20:06.000Z',
createdAt: '2021-08-03T19:20:06.000Z',
personId: '1',
activityId: '234',
companyId: '1',
id: '123',
};

View File

@ -37,7 +37,6 @@ const mocks: MockedResponse[] = [
edges {
node {
__typename
activityId
authorId
companyId
createdAt

View File

@ -51,7 +51,6 @@ const mocks: MockedResponse[] = [
edges {
node {
__typename
activityId
authorId
companyId
createdAt
@ -138,6 +137,9 @@ const mocks: MockedResponse[] = [
rocketId
taskId
updatedAt
workflowId
workflowRunId
workflowVersionId
workspaceMemberId
}
}

View File

@ -317,6 +317,219 @@ export const mocks = [
workspaceMemberId
}
}
companyId
createdAt
deletedAt
id
note {
__typename
body
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
id
position
title
updatedAt
}
noteId
opportunity {
__typename
amount {
amountMicros
currencyCode
}
closeDate
companyId
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
id
name
pointOfContactId
position
stage
updatedAt
}
opportunityId
person {
__typename
avatarUrl
city
companyId
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
emails {
primaryEmail
additionalEmails
}
id
intro
jobTitle
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
name {
firstName
lastName
}
performanceRating
phones {
primaryPhoneNumber
primaryPhoneCountryCode
additionalPhones
}
position
updatedAt
whatsapp {
primaryPhoneNumber
primaryPhoneCountryCode
additionalPhones
}
workPreference
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
}
personId
position
rocket {
__typename
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
id
name
position
updatedAt
}
rocketId
task {
__typename
assigneeId
body
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
dueAt
id
position
status
title
updatedAt
}
taskId
updatedAt
view {
__typename
createdAt
deletedAt
icon
id
isCompact
kanbanFieldMetadataId
key
name
objectMetadataId
position
type
updatedAt
}
viewId
workflow {
__typename
createdAt
deletedAt
id
lastPublishedVersionId
name
position
statuses
updatedAt
}
workflowId
workflowRun {
__typename
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
endedAt
id
name
output
position
startedAt
status
updatedAt
workflowId
workflowVersionId
}
workflowRunId
workflowVersion {
__typename
createdAt
deletedAt
id
name
position
status
steps
trigger
updatedAt
workflowId
}
workflowVersionId
workspaceMember {
__typename
avatarUrl
colorScheme
createdAt
dateFormat
deletedAt
id
locale
name {
firstName
lastName
}
timeFormat
timeZone
updatedAt
userEmail
userId
}
workspaceMemberId
}
}
`,
variables: {
input: {
@ -575,6 +788,41 @@ export const mocks = [
updatedAt
}
workflowId
workflowRun {
__typename
createdAt
createdBy {
source
workspaceMemberId
name
}
deletedAt
endedAt
id
name
output
position
startedAt
status
updatedAt
workflowId
workflowVersionId
}
workflowRunId
workflowVersion {
__typename
createdAt
deletedAt
id
name
position
status
steps
trigger
updatedAt
workflowId
}
workflowVersionId
workspaceMember {
__typename
avatarUrl

View File

@ -3,7 +3,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
export const mapSoftDeleteFieldsToGraphQLQuery = (
objectMetadataItem: Pick<ObjectMetadataItem, 'fields'>,
): string => {
const softDeleteFields = ['id', 'deletedAt'];
const softDeleteFields = ['deletedAt', 'id'];
const fieldsThatShouldBeQueried = objectMetadataItem.fields.filter(
(field) => field.isActive && softDeleteFields.includes(field.name),

View File

@ -17,7 +17,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ZERO_RELATIONS = `
id
intro
jobTitle
linkedinLink{
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
@ -49,27 +49,10 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ZERO_RELATIONS = `
export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
__typename
activityTargets {
edges {
node {
__typename
activityId
companyId
createdAt
deletedAt
id
opportunityId
personId
rocketId
updatedAt
}
}
}
attachments {
edges {
node {
__typename
activityId
authorId
companyId
createdAt
@ -190,6 +173,8 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
updatedAt
viewId
workflowId
workflowRunId
workflowVersionId
workspaceMemberId
}
}
@ -308,6 +293,9 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
rocketId
taskId
updatedAt
workflowId
workflowRunId
workflowVersionId
workspaceMemberId
}
}

View File

@ -15,5 +15,7 @@ export const variables = {
};
export const responseData = {
__typename: 'Person',
deletedAt: '2024-02-14T09:45:00Z',
id: 'a7286b9a-c039-4a89-9567-2dfa7953cda9',
};

View File

@ -99,20 +99,6 @@ export const query = gql`
}
city
email
activityTargets {
edges {
node {
__typename
id
updatedAt
createdAt
personId
activityId
companyId
id
}
}
}
jobTitle
favorites {
edges {
@ -137,7 +123,6 @@ export const query = gql`
createdAt
name
personId
activityId
companyId
id
authorId

View File

@ -8,8 +8,8 @@ const expectedQueryTemplate = `
mutation DeleteOnePerson($idToDelete: ID!) {
deletePerson(id: $idToDelete) {
__typename
deletedAt
id
deletedAt
}
}
`.replace(/\s/g, '');

View File

@ -47,22 +47,6 @@ const mocks: MockedResponse[] = [
userId
}
accountOwnerId
activityTargets {
edges {
node {
__typename
activityId
companyId
createdAt
deletedAt
id
opportunityId
personId
rocketId
updatedAt
}
}
}
address {
addressStreet1
addressStreet2
@ -81,7 +65,6 @@ const mocks: MockedResponse[] = [
edges {
node {
__typename
activityId
authorId
companyId
createdAt
@ -129,6 +112,8 @@ const mocks: MockedResponse[] = [
updatedAt
viewId
workflowId
workflowRunId
workflowVersionId
workspaceMemberId
}
}
@ -278,6 +263,9 @@ const mocks: MockedResponse[] = [
rocketId
taskId
updatedAt
workflowId
workflowRunId
workflowVersionId
workspaceMemberId
}
}

View File

@ -46,22 +46,6 @@ const companyMocks = [
userId
}
accountOwnerId
activityTargets {
edges {
node {
__typename
activityId
companyId
createdAt
deletedAt
id
opportunityId
personId
rocketId
updatedAt
}
}
}
address {
addressStreet1
addressStreet2
@ -80,7 +64,6 @@ const companyMocks = [
edges {
node {
__typename
activityId
authorId
companyId
createdAt

View File

@ -88,19 +88,6 @@ export const query = gql`
}
city
email
activityTargets {
edges {
node {
id
updatedAt
createdAt
personId
activityId
companyId
id
}
}
}
jobTitle
favorites {
edges {
@ -124,7 +111,6 @@ export const query = gql`
createdAt
name
personId
activityId
companyId
id
authorId

View File

@ -88,35 +88,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: null,
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [
{
__typename: 'ActivityTargetEdge',
node: {
__typename: 'ActivityTarget',
id: '97114d7e-2a80-4401-af58-36c88e13e852',
activityId: '737a6c31-610a-457b-b087-791ac700fa46',
createdAt: '2023-11-24T13:15:03.523Z',
updatedAt: '2023-11-24T13:15:03.523Z',
companyId: '04b2e9f5-0713-40a5-8216-82802401d33e',
personId: null,
},
},
{
__typename: 'ActivityTargetEdge',
node: {
__typename: 'ActivityTarget',
id: 'cb29d37a-3d5e-4efb-afa3-38f4bff69912',
activityId: '3c6ea4a3-f71d-4c31-9dfa-f868a5de4091',
createdAt: '2023-11-24T13:14:57.628Z',
updatedAt: '2023-11-24T13:14:57.628Z',
companyId: '04b2e9f5-0713-40a5-8216-82802401d33e',
personId: null,
},
},
],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -339,10 +310,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -489,10 +456,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -554,10 +517,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -755,10 +714,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -820,10 +775,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -885,10 +836,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -950,10 +897,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -1048,10 +991,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -1146,10 +1085,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -1211,10 +1146,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -1276,10 +1207,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,
@ -1426,10 +1353,6 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [
secondaryLinks: [],
__typename: 'Links',
},
activityTargets: {
__typename: 'ActivityTargetConnection',
edges: [],
},
annualRecurringRevenue: {
__typename: 'Currency',
amountMicros: null,