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

🐛 Bugfix for jumbled sorting of experiment list for lower and upper case experiment names #991

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 12 additions & 6 deletions backend/packages/Upgrade/src/api/services/ExperimentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -757,7 +763,7 @@ export class ExperimentService {
this.checkConditionCodeDefault(conditions);

// creating condition docs
const conditionDocToSave: Array<Partial<Omit <ExperimentCondition, 'levelCombinationElements'>>> =
const conditionDocToSave: Array<Partial<Omit<ExperimentCondition, 'levelCombinationElements'>>> =
(conditions &&
conditions.length > 0 &&
conditions.map((condition: ConditionValidator) => {
Expand Down Expand Up @@ -796,7 +802,7 @@ export class ExperimentService {
})
);
decisionPoint.id = decisionPoint.id || uuid();
return { ...decisionPoint, experiment: experimentDoc }
return { ...decisionPoint, experiment: experimentDoc };
})) ||
[];

Expand Down Expand Up @@ -1517,7 +1523,7 @@ export class ExperimentService {
return { ...experiment, factors: updatedFactors, conditionPayloads: updatedConditionPayloads };
}

private includeExcludeSegmentCreation (
private includeExcludeSegmentCreation(
experimentSegment: ParticipantsValidator,
experimentDocSegmentData: ExperimentSegmentInclusion | ExperimentSegmentExclusion,
experimentId: string,
Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down