From 0a45c617ab62556bc5d0d61be248d1c0a0c7bca6 Mon Sep 17 00:00:00 2001 From: pratik Date: Tue, 16 Jul 2024 15:48:00 +0530 Subject: [PATCH 1/2] remove groupId column from individualExclusion table --- .../Upgrade/src/api/models/IndividualExclusion.ts | 3 --- ...4249413-removeGroupIdFromIndividualExclusion.ts | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 backend/packages/Upgrade/src/database/migrations/1721124249413-removeGroupIdFromIndividualExclusion.ts diff --git a/backend/packages/Upgrade/src/api/models/IndividualExclusion.ts b/backend/packages/Upgrade/src/api/models/IndividualExclusion.ts index fa39ad97c6..f8ef8ac3f4 100644 --- a/backend/packages/Upgrade/src/api/models/IndividualExclusion.ts +++ b/backend/packages/Upgrade/src/api/models/IndividualExclusion.ts @@ -14,9 +14,6 @@ export class IndividualExclusion extends BaseModel { @ManyToOne(() => Experiment, { onDelete: 'CASCADE' }) public experiment: Experiment; - @Column({ nullable: true }) - public groupId?: string; - @IsNotEmpty() @Column({ type: 'enum', enum: EXCLUSION_CODE, nullable: true }) public exclusionCode: EXCLUSION_CODE; diff --git a/backend/packages/Upgrade/src/database/migrations/1721124249413-removeGroupIdFromIndividualExclusion.ts b/backend/packages/Upgrade/src/database/migrations/1721124249413-removeGroupIdFromIndividualExclusion.ts new file mode 100644 index 0000000000..712bcd7529 --- /dev/null +++ b/backend/packages/Upgrade/src/database/migrations/1721124249413-removeGroupIdFromIndividualExclusion.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class removeGroupIdFromIndividualExclusion1721124249413 implements MigrationInterface { + name = 'removeGroupIdFromIndividualExclusion1721124249413' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "individual_exclusion" DROP COLUMN "groupId"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "individual_exclusion" ADD "groupId" character varying`); + } + +} From 2aa5ba238772324c5d7a81280a525db16939411d Mon Sep 17 00:00:00 2001 From: pratik Date: Tue, 16 Jul 2024 18:21:20 +0530 Subject: [PATCH 2/2] remove groupId from assignment service --- .../api/services/ExperimentAssignmentService.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts index e34a6773f1..c06909e2e3 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts @@ -1290,10 +1290,9 @@ export class ExperimentAssignmentService { } if (status === MARKED_DECISION_POINT_STATUS.CONDITION_FAILED_TO_APPLY) { - const excludeUserDoc: Pick = { + const excludeUserDoc: Pick = { user, experiment, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: EXCLUSION_CODE.EXCLUDED_BY_CLIENT, }; await this.individualExclusionRepository.saveRawJson([excludeUserDoc]); @@ -1303,10 +1302,9 @@ export class ExperimentAssignmentService { // Don't mark the experiment if user or group are in exclusion list // TODO update this with segment implementation // Create the excludeUserDoc outside of the conditional statements to avoid repetition - const excludeUserDoc: Pick = { + const excludeUserDoc: Pick = { user, experiment, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: EXCLUSION_CODE.PARTICIPANT_ON_EXCLUSION_LIST, }; if (globallyExcluded.user || globallyExcluded.group.length) { @@ -1394,18 +1392,16 @@ export class ExperimentAssignmentService { if (!individualEnrollment && !individualExclusion) { if (assignmentUnit === ASSIGNMENT_UNIT.GROUP && !groupEnrollment) { - const excludeUserDoc: Pick = { + const excludeUserDoc: Pick = { user, experiment, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: EXCLUSION_CODE.REACHED_AFTER, }; promiseArray.push(this.individualExclusionRepository.saveRawJson([excludeUserDoc])); } else if (assignmentUnit !== ASSIGNMENT_UNIT.GROUP) { - const excludeUserDoc: Pick = { + const excludeUserDoc: Pick = { user, experiment, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: EXCLUSION_CODE.REACHED_AFTER, }; promiseArray.push(this.individualExclusionRepository.saveRawJson([excludeUserDoc])); @@ -1451,7 +1447,6 @@ export class ExperimentAssignmentService { > = { experiment, user, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: EXCLUSION_CODE.EXCLUDED_DUE_TO_GROUP_LOGIC, }; individualExclusion = individualExclusionDocument as IndividualExclusion; @@ -1484,7 +1479,6 @@ export class ExperimentAssignmentService { > = { experiment, user, - groupId: user?.workingGroup?.[experiment.group], exclusionCode: invalidGroup ? EXCLUSION_CODE.INVALID_GROUP_OR_WORKING_GROUP : EXCLUSION_CODE.NO_GROUP_SPECIFIED,