From 59e4b8d7a0d24bb2ce09cc48992396948fa21c7f Mon Sep 17 00:00:00 2001 From: pratik Date: Fri, 13 Oct 2023 17:48:36 +0530 Subject: [PATCH 1/3] moving data and query in within subject code block for latency issue in qa --- .../services/ExperimentAssignmentService.ts | 61 +++++-------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts index 50816c611b..e01b7c4820 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts @@ -650,21 +650,23 @@ export class ExperimentAssignmentService { ); }) ); - - const allSites = [], - allTargets = []; - filteredExperiments.forEach((exp) => { - exp.partitions.forEach((partition) => { - allSites.push(partition.site); - allTargets.push(partition.target); + let monitoredLogCounts: any[]; + if (filteredExperiments.some((e) => e.assignmentUnit === ASSIGNMENT_UNIT.WITHIN_SUBJECTS)) { + const allWithinSubjectsSites = [], + allWithinSubjectsTargets = []; + filteredExperiments.forEach((exp) => { + exp.partitions.forEach((partition) => { + allWithinSubjectsSites.push(partition.site); + allWithinSubjectsTargets.push(partition.target); + }); }); - }); - const monitoredLogCounts = await this.monitoredDecisionPointLogRepository.getAllMonitoredDecisionPointLog( - userId, - allSites, - allTargets, - logger - ); + monitoredLogCounts = await this.monitoredDecisionPointLogRepository.getAllMonitoredDecisionPointLog( + userId, + allWithinSubjectsSites, + allWithinSubjectsTargets, + logger + ); + } return filteredExperiments.reduce((accumulator, experiment, index) => { const assignment = experimentAssignment[index]; @@ -765,7 +767,6 @@ export class ExperimentAssignmentService { private createExperimentPool(experiments: Experiment[]): Experiment[][] { const pool: Experiment[][] = []; - // const localExperiment = [...experiments]; const decisionPointExperimentMap: Record = {}; @@ -782,36 +783,6 @@ export class ExperimentAssignmentService { pool.push(this.createPool(decisionPointToStart, decisionPointExperimentMap, [])); } - // while (localExperiment.length > 0) { - // const poolElements = []; - // const decisionPointHashMap: Record = {}; - - // for (let i = 0; i < localExperiment.length; i++) { - // // Push single element inside the pool - // const experiment = localExperiment[i]; - // if (i === 0) { - // poolElements.push(experiment); - // } - - // // add to decision point hashmap - // let isIntersecting = false; - // experiment.partitions.forEach((partition) => { - // const partitionId = `${partition.site}_${partition.target}`; - // if (partitionId in decisionPointHashMap) { - // isIntersecting = true; - // } - // decisionPointHashMap[partitionId] = decisionPointHashMap[partitionId] || []; - // decisionPointHashMap[partitionId].push(experiment); - // }); - - // if(isIntersecting) { - - // } - // } - - // // remove elements from localExperiment - // } - return pool; } From d581c1cc30621876c7e85fb2f1862ba16282d8c9 Mon Sep 17 00:00:00 2001 From: danoswaltCL <97542869+danoswaltCL@users.noreply.github.com> Date: Fri, 13 Oct 2023 11:22:45 -0400 Subject: [PATCH 2/3] initialize array and cleanup --- .../Upgrade/src/api/services/ExperimentAssignmentService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts index e01b7c4820..8da064a7ce 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts @@ -650,10 +650,10 @@ export class ExperimentAssignmentService { ); }) ); - let monitoredLogCounts: any[]; + let monitoredLogCounts = []; if (filteredExperiments.some((e) => e.assignmentUnit === ASSIGNMENT_UNIT.WITHIN_SUBJECTS)) { - const allWithinSubjectsSites = [], - allWithinSubjectsTargets = []; + const allWithinSubjectsSites = []; + const allWithinSubjectsTargets = []; filteredExperiments.forEach((exp) => { exp.partitions.forEach((partition) => { allWithinSubjectsSites.push(partition.site); From 74aeb231b5e613c9b5141a6a47f4cee6cb17cc3a Mon Sep 17 00:00:00 2001 From: danoswaltCL <97542869+danoswaltCL@users.noreply.github.com> Date: Fri, 13 Oct 2023 11:56:09 -0400 Subject: [PATCH 3/3] comment out within-subjects in UI --- .../experiment-overview/experiment-overview.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-overview/experiment-overview.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-overview/experiment-overview.component.ts index 310bf9dfac..dc4b79c768 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-overview/experiment-overview.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-overview/experiment-overview.component.ts @@ -40,7 +40,7 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy { unitOfAssignments = [ { value: ASSIGNMENT_UNIT.INDIVIDUAL }, { value: ASSIGNMENT_UNIT.GROUP }, - { value: ASSIGNMENT_UNIT.WITHIN_SUBJECTS }, + // { value: ASSIGNMENT_UNIT.WITHIN_SUBJECTS }, // #1063 temporarily removed within-subjects until solved ]; public ASSIGNMENT_UNIT = ASSIGNMENT_UNIT;