From 6ef44ae1401252921ed2fb54761eb24fcc008c00 Mon Sep 17 00:00:00 2001 From: RidhamShah Date: Thu, 21 Sep 2023 17:26:32 +0530 Subject: [PATCH] solve stratificationFactor creating multiple doc --- .../Upgrade/src/api/services/StratificationService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/StratificationService.ts b/backend/packages/Upgrade/src/api/services/StratificationService.ts index 09e3e90839..b2e964f16d 100644 --- a/backend/packages/Upgrade/src/api/services/StratificationService.ts +++ b/backend/packages/Upgrade/src/api/services/StratificationService.ts @@ -131,8 +131,12 @@ export class StratificationService { const stratificationFactorRemaining = userStratificationData.filter((factorData) => { return !stratificationFactorDetials.some((factor) => factor.stratificationFactorName === factorData.factor); }); - const stratificationFactorToSave = [...new Set(stratificationFactorRemaining)].map((stratificationFactor) => { - return { id: uuid(), stratificationFactorName: stratificationFactor.factor }; + + // create a SET of stratificationFactors not found in DB + const stratificationFactorToSave = [ + ...new Set(stratificationFactorRemaining.map((stratificationFactor) => stratificationFactor.factor)), + ].map((factor) => { + return { id: uuid(), stratificationFactorName: factor }; }); let userDocCreated: ExperimentUser[], stratificationFactorDocCreated: StratificationFactor[];