From 9c8bea0289beaacf7f78f1c37c67603d097c9c05 Mon Sep 17 00:00:00 2001 From: Pavel Gnedov Date: Mon, 9 Dec 2024 15:06:12 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B2=20DailyEccmV2R?= =?UTF-8?q?eportService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/reports/daily-eccm-v2.report.service.ts | 53 +++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/reports/daily-eccm-v2.report.service.ts b/src/reports/daily-eccm-v2.report.service.ts index fc2150d..caaefe7 100644 --- a/src/reports/daily-eccm-v2.report.service.ts +++ b/src/reports/daily-eccm-v2.report.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; export type Params = any; // TODO @@ -13,7 +13,54 @@ export type Report = { @Injectable() export class DailyEccmV2ReportService { - constructor(params: Params) { - return; + // TODO: apply logger for all methods + private logger = new Logger(DailyEccmV2ReportService.name); + + private jobs: any[] = []; + + addJob(job: any) { + this.jobs.push(job); + } + + getJobs() { + return this.jobs; + } + + getJob(jobId: string) { + return this.jobs.find((job) => job.id === jobId); + } + + removeJob(jobId: string) { + this.jobs.splice(this.jobs.indexOf(jobId), 1); + } + + startAllJobs() { + this.jobs.forEach((job) => { + job.start(); + }); + } + + startJob(jobId: string) { + const job = this.getJob(jobId); + if (job) { + job.start(); + } + } + + stopAllJobs() { + this.jobs.forEach((job) => { + job.stop(); + }); + } + + stopJob(jobId: string) { + const job = this.getJob(jobId); + if (job) { + job.stop(); + } + } + + autoScanJobs() { + throw new Error('Method not implemented.'); } }