From 1cf60ea4bd2ee7c8067e5054fef2e3931dc2ee92 Mon Sep 17 00:00:00 2001 From: pratik Date: Fri, 1 Sep 2023 14:20:07 +0530 Subject: [PATCH] fix for jumbled sorting of exp list for lower and upper case exp names --- .../src/api/services/ExperimentService.ts | 18 ++++++++++++------ .../experiment-list.component.ts | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentService.ts index 95c6fbaebe..fb8e3bb87a 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentService.ts @@ -62,7 +62,13 @@ import { Level } from '../models/Level'; import { LevelRepository } from '../repositories/LevelRepository'; import { LevelCombinationElement } from '../models/LevelCombinationElement'; import { LevelCombinationElementRepository } from '../repositories/LevelCombinationElements'; -import { ConditionValidator, ExperimentDTO, FactorValidator, PartitionValidator, ParticipantsValidator } from '../DTO/ExperimentDTO'; +import { + ConditionValidator, + ExperimentDTO, + FactorValidator, + PartitionValidator, + ParticipantsValidator, +} from '../DTO/ExperimentDTO'; import { ConditionPayloadDTO } from '../DTO/ConditionPayloadDTO'; import { FactorDTO } from '../DTO/FactorDTO'; import { LevelDTO } from '../DTO/LevelDTO'; @@ -165,7 +171,7 @@ export class ExperimentService { .whereInIds(expIds); if (sortParams) { - queryBuilderToReturn = queryBuilderToReturn.addOrderBy(`experiment.${sortParams.key}`, sortParams.sortAs); + queryBuilderToReturn = queryBuilderToReturn.addOrderBy(`LOWER(experiment.${sortParams.key})`, sortParams.sortAs); } const experiments = await queryBuilderToReturn.getMany(); return experiments.map((experiment) => { @@ -757,7 +763,7 @@ export class ExperimentService { this.checkConditionCodeDefault(conditions); // creating condition docs - const conditionDocToSave: Array>> = + const conditionDocToSave: Array>> = (conditions && conditions.length > 0 && conditions.map((condition: ConditionValidator) => { @@ -796,7 +802,7 @@ export class ExperimentService { }) ); decisionPoint.id = decisionPoint.id || uuid(); - return { ...decisionPoint, experiment: experimentDoc } + return { ...decisionPoint, experiment: experimentDoc }; })) || []; @@ -1517,7 +1523,7 @@ export class ExperimentService { return { ...experiment, factors: updatedFactors, conditionPayloads: updatedConditionPayloads }; } - private includeExcludeSegmentCreation ( + private includeExcludeSegmentCreation( experimentSegment: ParticipantsValidator, experimentDocSegmentData: ExperimentSegmentInclusion | ExperimentSegmentExclusion, experimentId: string, @@ -1618,7 +1624,7 @@ export class ExperimentService { const array = condition.levelCombinationElements.map((elements) => { elements.id = elements.id || uuid(); // elements.condition = condition; - return { ...elements, condition: condition } + return { ...elements, condition: condition }; }); allLevelCombinationElements.push(...array); }); diff --git a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-list/experiment-list.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-list/experiment-list.component.ts index d118d3b263..51af4d390a 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-list/experiment-list.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-list/experiment-list.component.ts @@ -64,6 +64,8 @@ export class ExperimentListComponent implements OnInit, OnDestroy, AfterViewInit this.allExperimentsSub = this.experimentService.experiments$.subscribe((allExperiments) => { this.allExperiments = new MatTableDataSource(); this.allExperiments.data = [...allExperiments]; + this.allExperiments.sortingDataAccessor = (item, property) => + property === 'name' ? item.name.toLowerCase() : item[property]; this.allExperiments.sort = this.sort; this.applyFilter(this.searchValue); });