Add KanbanFieldMetadataId on View standard object (#4604)

* Add KanbanFieldMetadataId on View standard object

* Deprecate Pipeline step

* Fix

* Use Constants instead of raw ids

* Fix

* Fix query runner

* Fix according to review

* Fix tests

* Fix tests

* Fix tests
This commit is contained in:
Charles Bochet
2024-03-21 18:08:27 +01:00
committed by GitHub
parent cc0e3c8a9a
commit 3fa8c4bace
36 changed files with 424 additions and 1486 deletions

View File

@ -9,9 +9,6 @@ const getRandomProbability = () => {
return firstDigit / 10;
};
const getRandomPipelineStepId = (pipelineStepIds: { id: string }[]) =>
pipelineStepIds[Math.floor(Math.random() * pipelineStepIds.length)].id;
const getRandomStage = () => {
const stages = ['NEW', 'SCREENING', 'MEETING', 'PROPOSAL', 'CUSTOMER'];
@ -24,14 +21,7 @@ const generateRandomAmountMicros = () => {
return firstDigit * 10000000000;
};
// Function to generate the array of opportunities
// companiesWithPeople - selecting from the db companies and 1 person related to the company.id to use companyId, pointOfContactId and personId
// pipelineStepIds - selecting from the db pipeline, getting random id from selected to use as pipelineStepId
const generateOpportunities = (
companies,
pipelineStepIds: { id: string }[],
) => {
const generateOpportunities = (companies) => {
return companies.map((company) => ({
id: v4(),
amountAmountMicros: generateRandomAmountMicros(),
@ -39,13 +29,12 @@ const generateOpportunities = (
closeDate: new Date(),
stage: getRandomStage(),
probability: getRandomProbability(),
pipelineStepId: getRandomPipelineStepId(pipelineStepIds),
pointOfContactId: company.personId,
companyId: company.id,
}));
};
export const seedDemoOpportunity = async (
export const opportunityPrefillDemoData = async (
entityManager: EntityManager,
schemaName: string,
) => {
@ -55,14 +44,8 @@ export const seedDemoOpportunity = async (
LEFT JOIN ${schemaName}.person ON company.id = "person"."companyId"
LIMIT 50`,
);
const pipelineStepIds = await entityManager?.query(
`SELECT id FROM ${schemaName}."pipelineStep"`,
);
const opportunities = generateOpportunities(
companiesWithPeople,
pipelineStepIds,
);
const opportunities = generateOpportunities(companiesWithPeople);
await entityManager
.createQueryBuilder()
@ -74,7 +57,6 @@ export const seedDemoOpportunity = async (
'closeDate',
'stage',
'probability',
'pipelineStepId',
'pointOfContactId',
'companyId',
'position',