Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix/multiple edit in design stepper throwing error #846

Merged
merged 2 commits into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions backend/packages/Upgrade/src/api/services/ExperimentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,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(
Expand All @@ -910,6 +910,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(
Expand All @@ -918,18 +933,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 };
Expand Down