From 4a2959edaf32324d9fcf5a0704ffdb44cd41718c Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Wed, 3 Jan 2024 11:34:00 +0100 Subject: [PATCH] Fixing solo job running --- src/backend/middlewares/admin/AdminMWs.ts | 8 +++++--- src/common/entities/job/JobDTO.ts | 7 +++++++ src/frontend/app/ui/settings/scheduled-jobs.service.ts | 10 +++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/backend/middlewares/admin/AdminMWs.ts b/src/backend/middlewares/admin/AdminMWs.ts index 68fc7f90..199b2932 100644 --- a/src/backend/middlewares/admin/AdminMWs.ts +++ b/src/backend/middlewares/admin/AdminMWs.ts @@ -3,6 +3,7 @@ import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error'; import {ObjectManagers} from '../../model/ObjectManagers'; import {StatisticDTO} from '../../../common/entities/settings/StatisticDTO'; import {MessengerRepository} from '../../model/messenger/MessengerRepository'; +import {JobStartDTO} from '../../../common/entities/job/JobDTO'; export class AdminMWs { public static async loadStatistic( @@ -81,9 +82,10 @@ export class AdminMWs { ): Promise { try { const id = req.params['id']; - const JobConfig: Record = req.body.config; - const soloRun: boolean = req.body.soloRun; - const allowParallelRun: boolean = req.body.allowParallelRun; + const jobStart: JobStartDTO = req.body; + const JobConfig: Record = jobStart.config; + const soloRun: boolean = jobStart.soloRun; + const allowParallelRun: boolean = jobStart.allowParallelRun; await ObjectManagers.getInstance().JobManager.run( id, JobConfig, diff --git a/src/common/entities/job/JobDTO.ts b/src/common/entities/job/JobDTO.ts index 3e364f2e..ac03c222 100644 --- a/src/common/entities/job/JobDTO.ts +++ b/src/common/entities/job/JobDTO.ts @@ -26,6 +26,13 @@ export interface JobDTO { ConfigTemplate: DynamicConfig[]; } + +export interface JobStartDTO { + soloRun: boolean; + config?: Record; + allowParallelRun: boolean; +} + export const JobDTOUtils = { getHashName: (jobName: string, config: any = {}) => { const sorted = Object.keys(config).sort().reduce((ret, key) => `${ret},${key}:${JSON.stringify(config[key])}`, ''); diff --git a/src/frontend/app/ui/settings/scheduled-jobs.service.ts b/src/frontend/app/ui/settings/scheduled-jobs.service.ts index 849b2d87..4f1eff84 100644 --- a/src/frontend/app/ui/settings/scheduled-jobs.service.ts +++ b/src/frontend/app/ui/settings/scheduled-jobs.service.ts @@ -3,7 +3,7 @@ import {BehaviorSubject} from 'rxjs'; import {JobProgressDTO, JobProgressStates, OnTimerJobProgressDTO,} from '../../../../common/entities/job/JobProgressDTO'; import {NetworkService} from '../../model/network/network.service'; import {JobScheduleDTO} from '../../../../common/entities/job/JobScheduleDTO'; -import {JobDTO, JobDTOUtils} from '../../../../common/entities/job/JobDTO'; +import {JobDTO, JobDTOUtils, JobStartDTO} from '../../../../common/entities/job/JobDTO'; import {BackendtextService} from '../../model/backendtext.service'; import {NotificationService} from '../../model/notification.service'; import {DynamicConfig} from '../../../../common/entities/DynamicConfig'; @@ -85,8 +85,8 @@ export class ScheduledJobsService { public async start( jobName: string, - config?: any, - soloStart = false, + config?: Record, + soloRun = false, allowParallelRun = false ): Promise { try { @@ -96,8 +96,8 @@ export class ScheduledJobsService { { config, allowParallelRun, - soloStart, - } + soloRun, + } as JobStartDTO ); // placeholder to force showing running job this.addDummyProgress(jobName, config);