From 06320d94afa3500b0f8f8c6bf5b11763132e67e6 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 2 May 2019 11:25:33 +0530 Subject: [PATCH 1/2] Fixing the timing issue with project creation. Now we are not making a call to fetch the phases again because we already have that data available in the payload of the project creation call. --- src/projects/actions/project.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index 02a28bd33..b147417c9 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -235,11 +235,12 @@ function createTimelineAndMilestoneForProduct(product, phase) { * @returns {Promise} project */ function createProductsTimelineAndMilestone(project) { - return getAllProjectProducts(project) - .then((products) => - Promise.all(products.map(createTimelineAndMilestoneForProduct)) - ) - .then(() => project) + if (project.phases) { + const products = _.flatten(_.map(project.phases, 'products')) + return Promise.all(products.map(createTimelineAndMilestoneForProduct)).then(() => project) + } else { + console.log('We did not receive the phases for the project. Hence timeline and milestones are not created') + } } export function createProduct(project, productTemplate, phases, timelines) { From 7c19adb8d5ffd8d52b3ec92553369976bcd31eb8 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 2 May 2019 11:33:16 +0530 Subject: [PATCH 2/2] Lint fix --- src/projects/actions/project.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index b147417c9..8d04333df 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -203,10 +203,10 @@ export function createProject(newProject) { * * @returns {Promise<[]>} list of products */ -function getAllProjectProducts(project) { - return getProjectPhasesWithProducts(project.id) - .then((phases) => _.flatten(_.map(phases, 'products'))) -} +// function getAllProjectProducts(project, fromDB = false) { +// return getProjectPhasesWithProducts(project.id, fromDB) +// .then((phases) => _.flatten(_.map(phases, 'products'))) +// } /** * Create timeline and milestones for a product