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

Solved multiple instance of experiments issue #1403

Merged
merged 4 commits into from
Apr 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const upload = multer({ storage: storage });
@Authorized()
@JsonController('/stratification')
export class StratificationController {
constructor(public stratificatonService: StratificationService) {}
constructor(public stratificationService: StratificationService) {}

/**
* @swagger
Expand All @@ -82,7 +82,7 @@ export class StratificationController {
*/
@Get()
public async getAllStratification(@Req() request: AppRequest): Promise<FactorStrata[]> {
return this.stratificatonService.getAllStratification(request.logger);
return this.stratificationService.getAllStratification(request.logger);
}

/**
Expand Down Expand Up @@ -121,7 +121,7 @@ export class StratificationController {
return Promise.reject(new Error(SERVER_ERROR.MISSING_PARAMS + ' : stratification Factor should not be null.'));
}

const csvData = await this.stratificatonService.getCSVDataByFactor(factor, request.logger);
const csvData = await this.stratificationService.getCSVDataByFactor(factor, request.logger);

// return csv file with appropriate headers to request;
res.setHeader('Content-Type', 'text/csv; charset=UTF-8');
Expand Down Expand Up @@ -160,7 +160,7 @@ export class StratificationController {
@Post()
@UseBefore(upload.single('file'))
public insertStratification(@Req() request: AppRequest): Promise<UserStratificationFactor[]> {
return this.stratificatonService.insertStratification(request.body[0].file, request.logger);
return this.stratificationService.insertStratification(request.body[0].file, request.logger);
}

/**
Expand Down Expand Up @@ -197,6 +197,6 @@ export class StratificationController {
if (!stratificationFactor) {
return Promise.reject(new Error(SERVER_ERROR.MISSING_PARAMS + ' : stratification Factor should not be null.'));
}
return this.stratificatonService.deleteStratification(stratificationFactor, request.logger);
return this.stratificationService.deleteStratification(stratificationFactor, request.logger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class StratificationService {
): FactorStrata[] {
const formattedResults = results.reduce((formatted, result) => {
const { factor, value, count, experimentIds } = result;
const expIds = experimentIds.filter((experimentId) => !!experimentId);
const expIds = new Set(experimentIds.filter((experimentId) => !!experimentId));
if (!formatted[factor]) {
formatted[factor] = { factor, factorValue: {}, experimentIds: expIds };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { DeleteStratificationComponent } from './delete-stratification/delete-st
import { StratificationFactor } from '../../../../../core/stratification-factors/store/stratification-factors.model';
import { Subscription } from 'rxjs';
import { StratificationFactorsService } from '../../../../../core/stratification-factors/stratification-factors.service';
import { ExperimentService } from '../../../../../core/experiments/experiments.service';
import { ExperimentNameVM } from '../../../../../core/experiments/store/experiments.model';

interface StratificationFactorsTableRow {
factor: string;
Expand All @@ -26,10 +28,18 @@ export class StratificationComponent implements OnInit {
isLoading$ = this.stratificationFactorsService.isLoading$;
stratificationFactorsForTable: StratificationFactorsTableRow[] = [];
displayedColumns: string[] = ['factor', 'status', 'summary', 'actions'];
allExperimentsName: ExperimentNameVM[];

constructor(private dialog: MatDialog, private stratificationFactorsService: StratificationFactorsService) {}
constructor(
private dialog: MatDialog,
private stratificationFactorsService: StratificationFactorsService,
private experimentService: ExperimentService
) {}

ngOnInit(): void {
this.experimentService.allExperimentNames$.subscribe((allExperimentNames) => {
this.allExperimentsName = allExperimentNames;
});
this.allStratificationFactorsSub = this.stratificationFactorsService.allStratificationFactors$.subscribe(
(allStratificationFactors) => {
this.allStratificationFactors = allStratificationFactors;
Expand All @@ -54,11 +64,14 @@ export class StratificationComponent implements OnInit {

factorSummary = totalUsers.toString() + ' ' + factorSummary + ' (' + tempSummary + ')';

const experimentNamesToShow = stratificationFactor.experimentIds.map((experimentId) => {
RidhamShah marked this conversation as resolved.
Show resolved Hide resolved
return this.allExperimentsName.find((experiment) => experiment.id === experimentId)?.name;
});
return {
factor: stratificationFactor.factor,
summary: factorSummary,
isUsed: this.checkStratificationFactorUsageStatus(stratificationFactor.experimentIds),
experimentIds: stratificationFactor.experimentIds,
experimentIds: experimentNamesToShow,
};
}
);
Expand Down Expand Up @@ -101,7 +114,7 @@ export class StratificationComponent implements OnInit {
}

getExperimentIdsTooltip(experimentIds: any[]): string {
return 'Experiment IDs: [' + experimentIds?.join(', ') + ']';
return 'Experiments: [' + experimentIds?.join(', ') + ']';
}

checkStratificationFactorUsageStatus(experimentIds: string[]) {
Expand Down
Loading