Rename recordPosition into position (#3864)

* Rename recordPosition into position

* Fix according to review

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thomas Trompette
2024-02-07 09:40:35 +01:00
committed by GitHub
parent eb54401afe
commit 9f59ddc059
10 changed files with 68 additions and 25 deletions

View File

@ -9,7 +9,13 @@ export const seedCompanies = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, ['id', 'name', 'domainName', 'address']) .into(`${schemaName}.${tableName}`, [
'id',
'name',
'domainName',
'address',
'position',
])
.orIgnore() .orIgnore()
.values([ .values([
{ {
@ -17,78 +23,91 @@ export const seedCompanies = async (
name: 'Linkedin', name: 'Linkedin',
domainName: 'linkedin.com', domainName: 'linkedin.com',
address: '', address: '',
position: 1,
}, },
{ {
id: '118995f3-5d81-46d6-bf83-f7fd33ea6102', id: '118995f3-5d81-46d6-bf83-f7fd33ea6102',
name: 'Facebook', name: 'Facebook',
domainName: 'facebook.com', domainName: 'facebook.com',
address: '', address: '',
position: 2,
}, },
{ {
id: '04b2e9f5-0713-40a5-8216-82802401d33e', id: '04b2e9f5-0713-40a5-8216-82802401d33e',
name: 'Qonto', name: 'Qonto',
domainName: 'qonto.com', domainName: 'qonto.com',
address: '', address: '',
position: 3,
}, },
{ {
id: '460b6fb1-ed89-413a-b31a-962986e67bb4', id: '460b6fb1-ed89-413a-b31a-962986e67bb4',
name: 'Microsoft', name: 'Microsoft',
domainName: 'microsoft.com', domainName: 'microsoft.com',
address: '', address: '',
position: 4,
}, },
{ {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278', id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
name: 'Airbnb', name: 'Airbnb',
domainName: 'airbnb.com', domainName: 'airbnb.com',
address: '', address: '',
position: 5,
}, },
{ {
id: '0d940997-c21e-4ec2-873b-de4264d89025', id: '0d940997-c21e-4ec2-873b-de4264d89025',
name: 'Google', name: 'Google',
domainName: 'google.com', domainName: 'google.com',
address: '', address: '',
position: 6,
}, },
{ {
id: '1d3a1c6e-707e-44dc-a1d2-30030bf1a944', id: '1d3a1c6e-707e-44dc-a1d2-30030bf1a944',
name: 'Netflix', name: 'Netflix',
domainName: 'netflix.com', domainName: 'netflix.com',
address: '', address: '',
position: 7,
}, },
{ {
id: '7a93d1e5-3f74-492d-a101-2a70f50a1645', id: '7a93d1e5-3f74-492d-a101-2a70f50a1645',
name: 'Libeo', name: 'Libeo',
domainName: 'libeo.io', domainName: 'libeo.io',
address: '', address: '',
position: 8,
}, },
{ {
id: '9d162de6-cfbf-4156-a790-e39854dcd4eb', id: '9d162de6-cfbf-4156-a790-e39854dcd4eb',
name: 'Claap', name: 'Claap',
domainName: 'claap.io', domainName: 'claap.io',
address: '', address: '',
position: 9,
}, },
{ {
id: 'aaffcfbd-f86b-419f-b794-02319abe8637', id: 'aaffcfbd-f86b-419f-b794-02319abe8637',
name: 'Hasura', name: 'Hasura',
domainName: 'hasura.io', domainName: 'hasura.io',
address: '', address: '',
position: 10,
}, },
{ {
id: 'f33dc242-5518-4553-9433-42d8eb82834b', id: 'f33dc242-5518-4553-9433-42d8eb82834b',
name: 'Wework', name: 'Wework',
domainName: 'wework.com', domainName: 'wework.com',
address: '', address: '',
position: 11,
}, },
{ {
id: 'a7bc68d5-f79e-40dd-bd06-c36e6abb4678', id: 'a7bc68d5-f79e-40dd-bd06-c36e6abb4678',
name: 'Samsung', name: 'Samsung',
domainName: 'samsung.com', domainName: 'samsung.com',
address: '', address: '',
position: 12,
}, },
{ {
id: 'a674fa6c-1455-4c57-afaf-dd5dc086361d', id: 'a674fa6c-1455-4c57-afaf-dd5dc086361d',
name: 'Algolia', name: 'Algolia',
domainName: 'algolia.com', domainName: 'algolia.com',
address: '', address: '',
position: 13,
}, },
]) ])
.execute(); .execute();

View File

@ -17,7 +17,7 @@ export const seedOpportunity = async (
'closeDate', 'closeDate',
'probability', 'probability',
'stage', 'stage',
'recordPosition', 'position',
'pipelineStepId', 'pipelineStepId',
'pointOfContactId', 'pointOfContactId',
'companyId', 'companyId',
@ -32,7 +32,7 @@ export const seedOpportunity = async (
closeDate: new Date(), closeDate: new Date(),
probability: 0.5, probability: 0.5,
stage: 'new', stage: 'new',
recordPosition: 0, position: 0,
pipelineStepId: '6edf4ead-006a-46e1-9c6d-228f1d0143c9', pipelineStepId: '6edf4ead-006a-46e1-9c6d-228f1d0143c9',
pointOfContactId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5', pointOfContactId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
@ -45,7 +45,7 @@ export const seedOpportunity = async (
closeDate: new Date(), closeDate: new Date(),
probability: 0.5, probability: 0.5,
stage: 'meeting', stage: 'meeting',
recordPosition: 0, position: 1,
pipelineStepId: 'd8361722-03fb-4e65-bd4f-ec9e52e5ec0a', pipelineStepId: 'd8361722-03fb-4e65-bd4f-ec9e52e5ec0a',
pointOfContactId: '93c72d2e-f517-42fd-80ae-14173b3b70ae', pointOfContactId: '93c72d2e-f517-42fd-80ae-14173b3b70ae',
companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102', companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102',
@ -58,7 +58,7 @@ export const seedOpportunity = async (
closeDate: new Date(), closeDate: new Date(),
probability: 0.5, probability: 0.5,
stage: 'proposal', stage: 'proposal',
recordPosition: 0, position: 2,
pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02', pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02',
pointOfContactId: '9b324a88-6784-4449-afdf-dc62cb8702f2', pointOfContactId: '9b324a88-6784-4449-afdf-dc62cb8702f2',
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
@ -71,7 +71,7 @@ export const seedOpportunity = async (
closeDate: new Date(), closeDate: new Date(),
probability: 0.5, probability: 0.5,
stage: 'proposal', stage: 'proposal',
recordPosition: 1, position: 3,
pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02', pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02',
pointOfContactId: '98406e26-80f1-4dff-b570-a74942528de3', pointOfContactId: '98406e26-80f1-4dff-b570-a74942528de3',
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',

View File

@ -17,6 +17,7 @@ export const seedPeople = async (
'city', 'city',
'companyId', 'companyId',
'email', 'email',
'position',
]) ])
.orIgnore() .orIgnore()
.values([ .values([
@ -28,6 +29,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
email: 'christoph.calisto@linkedin.com', email: 'christoph.calisto@linkedin.com',
position: 0,
}, },
{ {
id: '0aa00beb-ac73-4797-824e-87a1f5aea9e0', id: '0aa00beb-ac73-4797-824e-87a1f5aea9e0',
@ -37,6 +39,7 @@ export const seedPeople = async (
city: 'Los Angeles', city: 'Los Angeles',
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
email: 'sylvie.palmer@linkedin.com', email: 'sylvie.palmer@linkedin.com',
position: 1,
}, },
{ {
id: '93c72d2e-f517-42fd-80ae-14173b3b70ae', id: '93c72d2e-f517-42fd-80ae-14173b3b70ae',
@ -46,6 +49,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102', companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102',
email: 'christopher.gonzalez@qonto.com', email: 'christopher.gonzalez@qonto.com',
position: 2,
}, },
{ {
id: 'eeeacacf-eee1-4690-ad2c-8619e5b56a2e', id: 'eeeacacf-eee1-4690-ad2c-8619e5b56a2e',
@ -55,6 +59,7 @@ export const seedPeople = async (
city: 'Los Angeles', city: 'Los Angeles',
companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102', companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102',
email: 'ashley.parker@qonto.com', email: 'ashley.parker@qonto.com',
position: 3,
}, },
{ {
id: '9b324a88-6784-4449-afdf-dc62cb8702f2', id: '9b324a88-6784-4449-afdf-dc62cb8702f2',
@ -64,6 +69,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'nicholas.wright@microsoft.com', email: 'nicholas.wright@microsoft.com',
position: 4,
}, },
{ {
id: '1d151852-490f-4466-8391-733cfd66a0c8', id: '1d151852-490f-4466-8391-733cfd66a0c8',
@ -73,6 +79,7 @@ export const seedPeople = async (
city: 'New York', city: 'New York',
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'isabella.scott@microsoft.com', email: 'isabella.scott@microsoft.com',
position: 5,
}, },
{ {
id: '98406e26-80f1-4dff-b570-a74942528de3', id: '98406e26-80f1-4dff-b570-a74942528de3',
@ -82,6 +89,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'matthew.green@microsoft.com', email: 'matthew.green@microsoft.com',
position: 6,
}, },
{ {
id: 'a2e78a5f-338b-46df-8811-fa08c7d19d35', id: 'a2e78a5f-338b-46df-8811-fa08c7d19d35',
@ -91,6 +99,7 @@ export const seedPeople = async (
city: 'New York', city: 'New York',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'elizabeth.baker@airbnb.com', email: 'elizabeth.baker@airbnb.com',
position: 7,
}, },
{ {
id: 'ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016', id: 'ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016',
@ -100,6 +109,7 @@ export const seedPeople = async (
city: 'San Francisco', city: 'San Francisco',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'christopher.nelson@airbnb.com', email: 'christopher.nelson@airbnb.com',
position: 8,
}, },
{ {
id: '56955422-5d54-41b7-ba36-f0d20e1417ae', id: '56955422-5d54-41b7-ba36-f0d20e1417ae',
@ -109,6 +119,7 @@ export const seedPeople = async (
city: 'New York', city: 'New York',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'avery.carter@airbnb.com', email: 'avery.carter@airbnb.com',
position: 9,
}, },
{ {
id: '755035db-623d-41fe-92e7-dd45b7c568e1', id: '755035db-623d-41fe-92e7-dd45b7c568e1',
@ -118,6 +129,7 @@ export const seedPeople = async (
city: 'Los Angeles', city: 'Los Angeles',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'ethan.mitchell@google.com', email: 'ethan.mitchell@google.com',
position: 10,
}, },
{ {
id: '240da2ec-2d40-4e49-8df4-9c6a049190ef', id: '240da2ec-2d40-4e49-8df4-9c6a049190ef',
@ -127,6 +139,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'madison.perez@google.com', email: 'madison.perez@google.com',
position: 11,
}, },
{ {
id: '240da2ec-2d40-4e49-8df4-9c6a049190df', id: '240da2ec-2d40-4e49-8df4-9c6a049190df',
@ -136,6 +149,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: '0d940997-c21e-4ec2-873b-de4264d89025', companyId: '0d940997-c21e-4ec2-873b-de4264d89025',
email: 'bertrand.voulzy@google.com', email: 'bertrand.voulzy@google.com',
position: 12,
}, },
{ {
id: '240da2ec-2d40-4e49-8df4-9c6a049191de', id: '240da2ec-2d40-4e49-8df4-9c6a049191de',
@ -145,6 +159,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: 'a7bc68d5-f79e-40dd-bd06-c36e6abb4678', companyId: 'a7bc68d5-f79e-40dd-bd06-c36e6abb4678',
email: 'louis.duss@google.com', email: 'louis.duss@google.com',
position: 13,
}, },
{ {
id: '240da2ec-2d40-4e49-8df4-9c6a049191df', id: '240da2ec-2d40-4e49-8df4-9c6a049191df',
@ -154,6 +169,7 @@ export const seedPeople = async (
city: 'Seattle', city: 'Seattle',
companyId: 'a674fa6c-1455-4c57-afaf-dd5dc086361d', companyId: 'a674fa6c-1455-4c57-afaf-dd5dc086361d',
email: 'lorie.vladim@google.com', email: 'lorie.vladim@google.com',
position: 14,
}, },
]) ])
.execute(); .execute();

View File

@ -293,13 +293,13 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
}, },
{ {
type: FieldMetadataType.NUMBER, type: FieldMetadataType.NUMBER,
name: 'recordPosition', name: 'position',
label: 'Record position', label: 'Position',
targetColumnMap: { targetColumnMap: {
value: 'recordPosition', value: 'position',
}, },
icon: 'IconHierarchy2', icon: 'IconHierarchy2',
description: 'Record position', description: 'Position',
isNullable: true, isNullable: true,
isActive: true, isActive: true,
isCustom: false, isCustom: false,
@ -397,7 +397,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
columns: [ columns: [
{ {
action: WorkspaceMigrationColumnActionType.CREATE, action: WorkspaceMigrationColumnActionType.CREATE,
columnName: 'recordPosition', columnName: 'position',
columnType: 'float', columnType: 'float',
isNullable: true, isNullable: true,
} satisfies WorkspaceMigrationColumnCreate, } satisfies WorkspaceMigrationColumnCreate,

View File

@ -15,9 +15,12 @@ export const companyPrefillData = async (
'address', 'address',
'employees', 'employees',
'linkedinLinkUrl', 'linkedinLinkUrl',
'position',
]) ])
.orIgnore() .orIgnore()
.values(companiesDemo) .values(
companiesDemo.map((company, index) => ({ ...company, position: index })),
)
.returning('*') .returning('*')
.execute(); .execute();
}; };

View File

@ -38,7 +38,7 @@ const generateOpportunities = (
amountCurrencyCode: 'USD', amountCurrencyCode: 'USD',
closeDate: new Date(), closeDate: new Date(),
stage: getRandomStage(), stage: getRandomStage(),
recordPosition: null, position: null,
probability: getRandomProbability(), probability: getRandomProbability(),
pipelineStepId: getRandomPipelineStepId(pipelineStepIds), pipelineStepId: getRandomPipelineStepId(pipelineStepIds),
pointOfContactId: company.personId, pointOfContactId: company.personId,
@ -74,13 +74,18 @@ export const seedDemoOpportunity = async (
'amountCurrencyCode', 'amountCurrencyCode',
'closeDate', 'closeDate',
'stage', 'stage',
'recordPosition',
'probability', 'probability',
'pipelineStepId', 'pipelineStepId',
'pointOfContactId', 'pointOfContactId',
'companyId', 'companyId',
'position',
]) ])
.orIgnore() .orIgnore()
.values(opportunities) .values(
opportunities.map((opportunity, index) => ({
...opportunity,
position: index,
})),
)
.execute(); .execute();
}; };

View File

@ -19,7 +19,7 @@ export const personPrefillData = async (
jobTitle: person.jobTitle, jobTitle: person.jobTitle,
city: person.city, city: person.city,
avatarUrl: person.avatarUrl, avatarUrl: person.avatarUrl,
recordPosition: null, position: index,
companyId: companies[Math.floor(index / 2)].id, companyId: companies[Math.floor(index / 2)].id,
})); }));
@ -34,7 +34,7 @@ export const personPrefillData = async (
'jobTitle', 'jobTitle',
'city', 'city',
'avatarUrl', 'avatarUrl',
'recordPosition', 'position',
'companyId', 'companyId',
]) ])
.orIgnore() .orIgnore()

View File

@ -97,13 +97,13 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({ @FieldMetadata({
type: FieldMetadataType.NUMBER, type: FieldMetadataType.NUMBER,
label: 'RecordPosition', label: 'Position',
description: 'Record Position', description: 'Position',
icon: 'IconHierarchy2', icon: 'IconHierarchy2',
}) })
@IsSystem() @IsSystem()
@IsNullable() @IsNullable()
recordPosition: number; position: number;
// Relations // Relations
@FieldMetadata({ @FieldMetadata({

View File

@ -79,13 +79,13 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({ @FieldMetadata({
type: FieldMetadataType.NUMBER, type: FieldMetadataType.NUMBER,
label: 'RecordPosition', label: 'Position',
description: 'Record Position', description: 'Position',
icon: 'IconHierarchy2', icon: 'IconHierarchy2',
}) })
@IsSystem() @IsSystem()
@IsNullable() @IsNullable()
recordPosition: number; position: number;
// Relations // Relations
@FieldMetadata({ @FieldMetadata({

View File

@ -94,13 +94,13 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({ @FieldMetadata({
type: FieldMetadataType.NUMBER, type: FieldMetadataType.NUMBER,
label: 'RecordPosition', label: 'Position',
description: 'Record Position', description: 'Record Position',
icon: 'IconHierarchy2', icon: 'IconHierarchy2',
}) })
@IsSystem() @IsSystem()
@IsNullable() @IsNullable()
recordPosition: number; position: number;
// Relations // Relations
@FieldMetadata({ @FieldMetadata({