Skip to content

Commit

Permalink
Merge pull request #1760 from CarnegieLearningWeb/hotfix/remove-group…
Browse files Browse the repository at this point in the history
…id-ind-exclusion

✨ Remove groupId column from individualExclusion table
  • Loading branch information
ppratikcr7 authored Jul 16, 2024
2 parents 532e05b + 2aa5ba2 commit b132e1e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,10 +1290,9 @@ export class ExperimentAssignmentService {
}

if (status === MARKED_DECISION_POINT_STATUS.CONDITION_FAILED_TO_APPLY) {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'groupId' | 'exclusionCode'> = {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'exclusionCode'> = {
user,
experiment,
groupId: user?.workingGroup?.[experiment.group],
exclusionCode: EXCLUSION_CODE.EXCLUDED_BY_CLIENT,
};
await this.individualExclusionRepository.saveRawJson([excludeUserDoc]);
Expand All @@ -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<IndividualExclusion, 'user' | 'experiment' | 'groupId' | 'exclusionCode'> = {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'exclusionCode'> = {
user,
experiment,
groupId: user?.workingGroup?.[experiment.group],
exclusionCode: EXCLUSION_CODE.PARTICIPANT_ON_EXCLUSION_LIST,
};
if (globallyExcluded.user || globallyExcluded.group.length) {
Expand Down Expand Up @@ -1394,18 +1392,16 @@ export class ExperimentAssignmentService {

if (!individualEnrollment && !individualExclusion) {
if (assignmentUnit === ASSIGNMENT_UNIT.GROUP && !groupEnrollment) {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'groupId' | 'exclusionCode'> = {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'exclusionCode'> = {
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<IndividualExclusion, 'user' | 'experiment' | 'groupId' | 'exclusionCode'> = {
const excludeUserDoc: Pick<IndividualExclusion, 'user' | 'experiment' | 'exclusionCode'> = {
user,
experiment,
groupId: user?.workingGroup?.[experiment.group],
exclusionCode: EXCLUSION_CODE.REACHED_AFTER,
};
promiseArray.push(this.individualExclusionRepository.saveRawJson([excludeUserDoc]));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class removeGroupIdFromIndividualExclusion1721124249413 implements MigrationInterface {
name = 'removeGroupIdFromIndividualExclusion1721124249413'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "individual_exclusion" DROP COLUMN "groupId"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "individual_exclusion" ADD "groupId" character varying`);
}

}

0 comments on commit b132e1e

Please sign in to comment.