From 4d25fa4e9a1f26f0d475270ad04ef83427e92f1d Mon Sep 17 00:00:00 2001 From: Yagnik Date: Mon, 8 May 2023 14:26:29 +0530 Subject: [PATCH] Resolved issue for error in multiple edit in design stepper --- .../src/api/services/ExperimentService.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentService.ts index 43ee1e1741..3d30fe3fc8 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentService.ts @@ -892,7 +892,7 @@ export class ExperimentService { let queryDocs: Query[]; let conditionPayloadDocs: ConditionPayloadDTO[]; try { - [conditionDocs, decisionPointDocs, conditionPayloadDocs, queryDocs] = await Promise.all([ + [conditionDocs, decisionPointDocs, queryDocs] = await Promise.all([ Promise.all( conditionDocToSave.map(async (conditionDoc) => { return this.experimentConditionRepository.upsertExperimentCondition( @@ -909,6 +909,21 @@ export class ExperimentService { ); }) ) as any, + Promise.all( + queriesDocToSave.map(async (queryDoc) => { + return this.queryRepository.upsertQuery(queryDoc, transactionalEntityManager); + }) + ) as any, + ]); + } catch (err) { + const error = err as Error; + error.message = `Error in creating conditions, decision points, queries "updateExperimentInDB"`; + logger.error(error); + throw error; + } + + try { + [conditionPayloadDocs] = await Promise.all([ Promise.all( conditionPayloadDocToSave.map(async (conditionPayload) => { return this.conditionPayloadRepository.upsertConditionPayload( @@ -917,18 +932,13 @@ export class ExperimentService { ); }) ) as any, - Promise.all( - queriesDocToSave.map(async (queryDoc) => { - return this.queryRepository.upsertQuery(queryDoc, transactionalEntityManager); - }) - ) as any, ]); } catch (err) { const error = err as Error; - error.message = `Error in creating conditions, decision points, conditionPayloads, queries "updateExperimentInDB"`; + error.message = `Error in creating conditionPayloads "updateExperimentInDB"`; logger.error(error); throw error; - } + } let conditionDocToReturn = conditionDocs.map((conditionDoc) => { return { ...conditionDoc, experiment: conditionDoc.experiment };