From 2bfcf54d0888bc6a3badccef9861199592f16574 Mon Sep 17 00:00:00 2001 From: pratik Date: Tue, 26 Nov 2024 11:13:36 +0530 Subject: [PATCH 1/4] fi for experiment schedular not working due to cyclin services dependency and findby old syntax --- .../Upgrade/src/api/services/ExperimentAssignmentService.ts | 2 -- .../packages/Upgrade/src/api/services/ExperimentService.ts | 3 ++- .../Upgrade/src/api/services/ScheduledJobService.ts | 6 +++--- .../test/unit/services/ExperimentAssignmentService.test.ts | 3 --- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts index 7e84feb202..243d8bdbab 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts @@ -29,7 +29,6 @@ import { ExperimentRepository } from '../repositories/ExperimentRepository'; import { IndividualExclusion } from '../models/IndividualExclusion'; import { GroupExclusion } from '../models/GroupExclusion'; import { Experiment } from '../models/Experiment'; -import { ScheduledJobService } from './ScheduledJobService'; import { ExperimentCondition } from '../models/ExperimentCondition'; import { v4 as uuid } from 'uuid'; import { PreviewUserService } from './PreviewUserService'; @@ -108,7 +107,6 @@ export class ExperimentAssignmentService { public previewUserService: PreviewUserService, public experimentUserService: ExperimentUserService, - public scheduledJobService: ScheduledJobService, public errorService: ErrorService, public settingService: SettingService, public segmentService: SegmentService, diff --git a/backend/packages/Upgrade/src/api/services/ExperimentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentService.ts index 8bb5053510..ad0362f12a 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentService.ts @@ -1,7 +1,7 @@ /* eslint-disable no-var */ import { GroupExclusion } from './../models/GroupExclusion'; import { ErrorWithType } from './../errors/ErrorWithType'; -import { Service } from 'typedi'; +import { Inject, Service } from 'typedi'; import { InjectDataSource, InjectRepository } from '../../typeorm-typedi-extensions'; import { ExperimentRepository } from '../repositories/ExperimentRepository'; import { @@ -121,6 +121,7 @@ export class ExperimentService { @InjectDataSource() private dataSource: DataSource, public previewUserService: PreviewUserService, public segmentService: SegmentService, + @Inject(() => ScheduledJobService) public scheduledJobService: ScheduledJobService, public errorService: ErrorService, public cacheService: CacheService, diff --git a/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts b/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts index 1a5fec1fe3..c9980029ca 100644 --- a/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts +++ b/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts @@ -28,7 +28,7 @@ export class ScheduledJobService { return await this.dataSource.transaction(async (transactionalEntityManager) => { try { const scheduledJobRepository = transactionalEntityManager.getRepository(ScheduledJob); - const scheduledJob = await scheduledJobRepository.findOne({ where: { id }, relations: ['experiment'] }); + const scheduledJob = await scheduledJobRepository.findOne({ where: { id: id }, relations: ['experiment'] }); const currentDate = new Date(); const timeDiff = Math.abs(currentDate.getTime() - scheduledJob.timeStamp.getTime()); @@ -44,7 +44,7 @@ export class ScheduledJobService { if (scheduledJob && scheduledJob.experiment) { const experimentRepository = transactionalEntityManager.getRepository(Experiment); const experiment = await experimentRepository.findOneBy({ id: scheduledJob.experiment.id }); - if (scheduledJob && experiment) { + if (experiment) { const systemUser = await transactionalEntityManager .getRepository(User) .findOneBy({ email: systemUserDoc.email }); @@ -75,7 +75,7 @@ export class ScheduledJobService { return await this.dataSource.transaction(async (transactionalEntityManager) => { try { const scheduledJobRepository = transactionalEntityManager.getRepository(ScheduledJob); - const scheduledJob = await scheduledJobRepository.findOne({ where: { id }, relations: ['experiment'] }); + const scheduledJob = await scheduledJobRepository.findOne({ where: { id: id }, relations: ['experiment'] }); const experimentRepository = transactionalEntityManager.getRepository(Experiment); const experiment = await experimentRepository.findOneBy({ id: scheduledJob.experiment.id }); diff --git a/backend/packages/Upgrade/test/unit/services/ExperimentAssignmentService.test.ts b/backend/packages/Upgrade/test/unit/services/ExperimentAssignmentService.test.ts index 340b02d3ed..9cdc5cb7e9 100644 --- a/backend/packages/Upgrade/test/unit/services/ExperimentAssignmentService.test.ts +++ b/backend/packages/Upgrade/test/unit/services/ExperimentAssignmentService.test.ts @@ -17,7 +17,6 @@ import { ExperimentAssignmentService } from '../../../src/api/services/Experimen import { ExperimentService } from '../../../src/api/services/ExperimentService'; import { ExperimentUserService } from '../../../src/api/services/ExperimentUserService'; import { PreviewUserService } from '../../../src/api/services/PreviewUserService'; -import { ScheduledJobService } from '../../../src/api/services/ScheduledJobService'; import { SegmentService } from '../../../src/api/services/SegmentService'; import { SettingService } from '../../../src/api/services/SettingService'; import { @@ -54,7 +53,6 @@ describe('Experiment Assignment Service Test', () => { const userStratificationFactorRepository = sinon.createStubInstance(UserStratificationFactorRepository); const previewUserServiceMock = sinon.createStubInstance(PreviewUserService); const experimentUserServiceMock = sinon.createStubInstance(ExperimentUserService); - const scheduledJobServiceMock = sinon.createStubInstance(ScheduledJobService); const errorServiceMock = sinon.createStubInstance(ErrorService); const settingServiceMock = sinon.createStubInstance(SettingService); const segmentServiceMock = sinon.createStubInstance(SegmentService); @@ -87,7 +85,6 @@ describe('Experiment Assignment Service Test', () => { userStratificationFactorRepository, previewUserServiceMock, experimentUserServiceMock, - scheduledJobServiceMock, errorServiceMock, settingServiceMock, segmentServiceMock, From ad3852d86a8e390d501a9cb2d6a1a524ed5cc0ec Mon Sep 17 00:00:00 2001 From: Yagnik Hingrajiya <50392803+Yagnik56@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:00:36 +0530 Subject: [PATCH 2/4] Disallow Editing (Name, Key, App Context) or Deleting an Enabled Feature Flag (#2123) * disable name, key and context input field for enabled feature flag and deletion of feature flag * addressed review comment * addressed review comment * update menuitems as observable to address review commnet * Addressed review comment --- .../upsert-feature-flag-modal.component.html | 2 +- .../upsert-feature-flag-modal.component.ts | 28 ++++++++++-- ...erview-details-section-card.component.html | 2 +- ...overview-details-section-card.component.ts | 45 ++++++++++--------- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.html b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.html index 0d9b0a2827..fd2a04e43b 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.html +++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.html @@ -9,7 +9,7 @@
Name - + {{ 'feature-flags.upsert-flag-modal.name-hint.text' | translate }} diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.ts index 7ddeacabca..c9dc28d075 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component.ts @@ -106,6 +106,23 @@ export class UpsertFeatureFlagModalComponent { this.listenForPrimaryButtonDisabled(); this.listenForDuplicateKey(); this.listenOnContext(); + + if (this.isDisabled()) { + this.disableRestrictedFields(); + } + } + + isDisabled() { + return ( + this.config.params.action === UPSERT_FEATURE_FLAG_ACTION.EDIT && + this.config.params.sourceFlag?.status === FEATURE_FLAG_STATUS.ENABLED + ); + } + + disableRestrictedFields(): void { + this.featureFlagForm.get('name')?.disable(); + this.featureFlagForm.get('key')?.disable(); + this.featureFlagForm.get('appContext')?.disable(); } createFeatureFlagForm(): void { @@ -234,10 +251,13 @@ export class UpsertFeatureFlagModalComponent { this.featureFlagsService.addFeatureFlag(flagRequest); } - createEditRequest( - { name, key, description, appContext, tags }: FeatureFlagFormData, - { id, status, filterMode }: FeatureFlag - ): void { + createEditRequest({ name, key, description, appContext, tags }: FeatureFlagFormData, sourceFlag: FeatureFlag): void { + const { id, status, filterMode } = sourceFlag; + if (sourceFlag.status === 'enabled') { + name = sourceFlag.name; + key = sourceFlag.key; + appContext = sourceFlag.context[0]; + } const flagRequest: UpdateFeatureFlagRequest = { id, name, diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.html b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.html index a33366df8a..ba838b5d5d 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.html +++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.html @@ -16,7 +16,7 @@ [slideToggleChecked]="flag.status === FEATURE_FLAG_STATUS.ENABLED" [slideToggleText]="'feature-flags.enable.text' | translate" [showMenuButton]="true" - [menuButtonItems]="menuButtonItems" + [menuButtonItems]="menuButtonItems$ | async" [isSectionCardExpanded]="isSectionCardExpanded" (slideToggleChange)="onSlideToggleChange($event, flag)" (menuButtonItemClick)="onMenuButtonItemClick($event, flag)" diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.ts index 212a8276eb..dadf0faf4c 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.ts @@ -16,7 +16,7 @@ import { FEATURE_FLAG_DETAILS_PAGE_ACTIONS, FeatureFlag, } from '../../../../../../../core/feature-flags/store/feature-flags.model'; -import { Observable, Subscription } from 'rxjs'; +import { combineLatest, map, Observable, Subscription } from 'rxjs'; import { MatDialogRef } from '@angular/material/dialog'; import { CommonSimpleConfirmationModalComponent } from '../../../../../../../shared-standalone-component-lib/components/common-simple-confirmation-modal/common-simple-confirmation-modal.component'; import { Router } from '@angular/router'; @@ -39,16 +39,21 @@ import { AuthService } from '../../../../../../../core/auth/auth.service'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class FeatureFlagOverviewDetailsSectionCardComponent implements OnInit, OnDestroy { - permissions$: Observable; - isSectionCardExpanded = true; @Output() sectionCardExpandChange = new EventEmitter(); - emailId = ''; + permissions$: Observable = this.authService.userPermissions$; featureFlag$ = this.featureFlagService.selectedFeatureFlag$; + flagAndPermissions$: Observable<{ flag: FeatureFlag; permissions: UserPermission }> = combineLatest([ + this.featureFlag$, + this.permissions$, + ]).pipe(map(([flag, permissions]) => ({ flag, permissions }))); + + subscriptions = new Subscription(); flagOverviewDetails$ = this.featureFlagService.selectedFlagOverviewDetails; shouldShowWarning$ = this.featureFlagService.shouldShowWarningForSelectedFlag$; - subscriptions = new Subscription(); confirmStatusChangeDialogRef: MatDialogRef; - menuButtonItems: IMenuButtonItem[]; + menuButtonItems$: Observable; + isSectionCardExpanded = true; + emailId = ''; constructor( private dialogService: DialogService, @@ -58,13 +63,20 @@ export class FeatureFlagOverviewDetailsSectionCardComponent implements OnInit, O ) {} ngOnInit(): void { - this.permissions$ = this.authService.userPermissions$; this.subscriptions.add(this.featureFlagService.currentUserEmailAddress$.subscribe((id) => (this.emailId = id))); - this.subscriptions.add( - this.permissions$.subscribe((permissions) => { - this.updateMenuItems(permissions); - }) + this.menuButtonItems$ = this.flagAndPermissions$.pipe( + map(({ flag, permissions }) => [ + { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EDIT, disabled: !permissions.featureFlags.update }, + { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.DUPLICATE, disabled: !permissions.featureFlags.create }, + { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EXPORT_DESIGN, disabled: false }, + { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EMAIL_DATA, disabled: true }, + { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.ARCHIVE, disabled: true }, + { + name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.DELETE, + disabled: !permissions?.featureFlags.delete || flag?.status === 'enabled', + }, + ]) ); } @@ -76,17 +88,6 @@ export class FeatureFlagOverviewDetailsSectionCardComponent implements OnInit, O return FILTER_MODE; } - private updateMenuItems(permissions: UserPermission): void { - this.menuButtonItems = [ - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EDIT, disabled: !permissions?.featureFlags.update }, - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.DUPLICATE, disabled: !permissions?.featureFlags.create }, - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EXPORT_DESIGN, disabled: false }, - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.EMAIL_DATA, disabled: true }, - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.ARCHIVE, disabled: true }, - { name: FEATURE_FLAG_DETAILS_PAGE_ACTIONS.DELETE, disabled: !permissions?.featureFlags.delete }, - ]; - } - onSlideToggleChange(event: MatSlideToggleChange, flag: FeatureFlag) { const slideToggleEvent = event.source; const newStatus = slideToggleEvent.checked ? FEATURE_FLAG_STATUS.ENABLED : FEATURE_FLAG_STATUS.DISABLED; From ad29d4c2b7f99067f2d58183c48d43fb4f176f87 Mon Sep 17 00:00:00 2001 From: Yagnik Hingrajiya <50392803+Yagnik56@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:31:28 +0530 Subject: [PATCH 3/4] Allow importing experiments with old payload (#2143) * Allow importing experiments with old payload structure for experiments older than version 5.3 * update code for failing code * update code for failing testcase code * update code for review comments --------- Co-authored-by: danoswaltCL <97542869+danoswaltCL@users.noreply.github.com> --- backend/packages/Upgrade/package-lock.json | 6 +++ backend/packages/Upgrade/package.json | 1 + .../Upgrade/src/api/DTO/ExperimentDTO.ts | 38 +++++++++++++++---- .../src/api/services/ExperimentService.ts | 24 +++++++++++- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/backend/packages/Upgrade/package-lock.json b/backend/packages/Upgrade/package-lock.json index 2d02a2b08a..58b1a3e20d 100644 --- a/backend/packages/Upgrade/package-lock.json +++ b/backend/packages/Upgrade/package-lock.json @@ -24,6 +24,7 @@ "chalk": "^5.3.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", + "compare-versions": "^6.1.1", "compression": "^1.7.4", "cors": "^2.8.5", "csv-stringify": "^6.4.5", @@ -5187,6 +5188,11 @@ "node": ">=4.0.0" } }, + "node_modules/compare-versions": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.1.tgz", + "integrity": "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==" + }, "node_modules/component-emitter": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", diff --git a/backend/packages/Upgrade/package.json b/backend/packages/Upgrade/package.json index 98e3018928..0804d2c9cc 100644 --- a/backend/packages/Upgrade/package.json +++ b/backend/packages/Upgrade/package.json @@ -71,6 +71,7 @@ "chalk": "^5.3.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", + "compare-versions": "^6.1.1", "compression": "^1.7.4", "cors": "^2.8.5", "csv-stringify": "^6.4.5", diff --git a/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts b/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts index 1e310e5522..ed4c3bd9b2 100644 --- a/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts +++ b/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts @@ -182,7 +182,7 @@ export class PartitionValidator { public excludeIfReached: boolean; } -class ConditionPayloadValidator { +abstract class BaseConditionPayloadValidator { @IsNotEmpty() @IsString() public id: string; @@ -191,7 +191,9 @@ class ConditionPayloadValidator { @ValidateNested() @Type(() => PayloadValidator) public payload: PayloadValidator; +} +export class ConditionPayloadValidator extends BaseConditionPayloadValidator { @IsNotEmpty() @IsString() public parentCondition: string; @@ -201,6 +203,16 @@ class ConditionPayloadValidator { public decisionPoint?: string; } +class OldConditionPayloadValidator extends BaseConditionPayloadValidator { + @IsNotEmpty() + @IsString() + public parentCondition: ConditionValidator; + + @IsOptional() + @IsString() + public decisionPoint?: PartitionValidator; +} + class MetricValidator { @IsNotEmpty() @IsString() @@ -322,7 +334,7 @@ class StratificationFactor { public stratificationFactorName: string; } -export class ExperimentDTO { +abstract class BaseExperimentWithoutPayload { @IsString() @IsOptional() public id?: string; @@ -418,12 +430,6 @@ export class ExperimentDTO { @Type(() => PartitionValidator) public partitions: PartitionValidator[]; - @IsOptional() - @IsArray() - @ValidateNested({ each: true }) - @Type(() => ConditionPayloadValidator) - public conditionPayloads?: ConditionPayloadValidator[]; - @IsOptional() @IsArray() @ValidateNested({ each: true }) @@ -455,6 +461,22 @@ export class ExperimentDTO { public type: EXPERIMENT_TYPE; } +export class ExperimentDTO extends BaseExperimentWithoutPayload { + @IsOptional() + @IsArray() + @ValidateNested({ each: true }) + @Type(() => ConditionPayloadValidator) + public conditionPayloads?: ConditionPayloadValidator[]; +} + +export class OldExperimentDTO extends BaseExperimentWithoutPayload { + @IsOptional() + @IsArray() + @ValidateNested({ each: true }) + @Type(() => OldConditionPayloadValidator) + public conditionPayloads?: OldConditionPayloadValidator[]; +} + export class ExperimentIdValidator { @IsNotEmpty() @IsUUID() diff --git a/backend/packages/Upgrade/src/api/services/ExperimentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentService.ts index 8bb5053510..2c156d70c3 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentService.ts @@ -73,6 +73,7 @@ import { ParticipantsValidator, ExperimentFile, ValidatedExperimentError, + OldExperimentDTO, } from '../DTO/ExperimentDTO'; import { ConditionPayloadDTO } from '../DTO/ConditionPayloadDTO'; import { FactorDTO } from '../DTO/FactorDTO'; @@ -85,6 +86,7 @@ import { validate } from 'class-validator'; import { plainToClass } from 'class-transformer'; import { StratificationFactorRepository } from '../repositories/StratificationFactorRepository'; import { ExperimentDetailsForCSVData } from '../repositories/AnalyticsRepository'; +import { compare } from 'compare-versions'; const errorRemovePart = 'instance of ExperimentDTO has failed the validation:\n - '; const stratificationErrorMessage = @@ -1525,7 +1527,14 @@ export class ExperimentService { } catch (error) { return { fileName: experimentFile.fileName, error: 'Invalid JSON' }; } - const newExperiment = plainToClass(ExperimentDTO, experiment); + + let newExperiment: ExperimentDTO; + if (compare(experiment.backendVersion, '5.3.0', '>=')) { + newExperiment = plainToClass(ExperimentDTO, experiment); + } else { + newExperiment = plainToClass(ExperimentDTO, this.experimentPayloadConverter(experiment)); + } + if (!(newExperiment instanceof ExperimentDTO)) { return { fileName: experimentFile.fileName, error: 'Invalid JSON' }; } @@ -1569,6 +1578,19 @@ export class ExperimentService { .filter((error) => error !== null); } + private experimentPayloadConverter(experiment: OldExperimentDTO): ExperimentDTO { + const updatedExperimentPayload = experiment.conditionPayloads.map((conditionPayload) => { + return { + ...conditionPayload, + parentCondition: conditionPayload.parentCondition.id, + decisionPoint: conditionPayload.decisionPoint.id, + }; + }); + + const newExperiment: ExperimentDTO = { ...experiment, conditionPayloads: updatedExperimentPayload }; + return newExperiment; + } + private async validateExperimentJSON(experiment: ExperimentDTO): Promise { let errorString = ''; await validate(experiment).then((errors) => { From d7f775e57e2f468b828108450c71b8fdbdc9f6f5 Mon Sep 17 00:00:00 2001 From: pratik Date: Tue, 3 Dec 2024 20:42:40 +0530 Subject: [PATCH 4/4] remove redundant id in findOne query for scheduled jobs --- .../packages/Upgrade/src/api/services/ScheduledJobService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts b/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts index c9980029ca..446bcaa25b 100644 --- a/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts +++ b/backend/packages/Upgrade/src/api/services/ScheduledJobService.ts @@ -28,7 +28,7 @@ export class ScheduledJobService { return await this.dataSource.transaction(async (transactionalEntityManager) => { try { const scheduledJobRepository = transactionalEntityManager.getRepository(ScheduledJob); - const scheduledJob = await scheduledJobRepository.findOne({ where: { id: id }, relations: ['experiment'] }); + const scheduledJob = await scheduledJobRepository.findOne({ where: { id }, relations: ['experiment'] }); const currentDate = new Date(); const timeDiff = Math.abs(currentDate.getTime() - scheduledJob.timeStamp.getTime()); @@ -75,7 +75,7 @@ export class ScheduledJobService { return await this.dataSource.transaction(async (transactionalEntityManager) => { try { const scheduledJobRepository = transactionalEntityManager.getRepository(ScheduledJob); - const scheduledJob = await scheduledJobRepository.findOne({ where: { id: id }, relations: ['experiment'] }); + const scheduledJob = await scheduledJobRepository.findOne({ where: { id }, relations: ['experiment'] }); const experimentRepository = transactionalEntityManager.getRepository(Experiment); const experiment = await experimentRepository.findOneBy({ id: scheduledJob.experiment.id });