@luisrodrigues/nestjs-scheduler-dashboard 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,9 @@ function TrackJob(cronTime, options) {
54
54
  const original = descriptor.value;
55
55
  const jobName = options?.name ?? `${target.constructor.name}.${String(propertyKey)}`;
56
56
  const jobNoOverlap = options?.noOverlap;
57
+ if (options?.disabled) {
58
+ scheduler_dash_context_1.SchedulerDashContext.disabledJobs.add(jobName);
59
+ }
57
60
  descriptor.value = async function (...args) {
58
61
  const noOverlap = jobNoOverlap ?? scheduler_dash_context_1.SchedulerDashContext.noOverlap;
59
62
  const storage = scheduler_dash_context_1.SchedulerDashContext.storage;
@@ -8,6 +8,7 @@ export declare class JobsService {
8
8
  cron: {
9
9
  name: string;
10
10
  cronExpression: string;
11
+ active: boolean;
11
12
  running: boolean;
12
13
  nextRun: string;
13
14
  history: import(".").JobExecution[];
@@ -23,6 +24,7 @@ export declare class JobsService {
23
24
  getJob(name: string): {
24
25
  name: string;
25
26
  cronExpression: string;
27
+ active: boolean;
26
28
  running: boolean;
27
29
  nextRun: string;
28
30
  history: import(".").JobExecution[];
@@ -17,6 +17,7 @@ const common_1 = require("@nestjs/common");
17
17
  const schedule_1 = require("@nestjs/schedule");
18
18
  const storage_abstract_1 = require("./storage/storage.abstract");
19
19
  const job_concurrency_1 = require("./decorators/job-concurrency");
20
+ const scheduler_dash_context_1 = require("./scheduler-dash.context");
20
21
  const scheduler_dash_constants_1 = require("./scheduler-dash.constants");
21
22
  function resolveNextRun(job) {
22
23
  try {
@@ -49,14 +50,18 @@ let JobsService = class JobsService {
49
50
  this.storage = storage;
50
51
  }
51
52
  getJobs() {
52
- const cron = [...this.schedulerRegistry.getCronJobs().entries()].map(([name, job]) => ({
53
- name,
54
- cronExpression: resolveCronExpression(job.cronTime),
55
- running: job.running ?? false,
56
- nextRun: resolveNextRun(job),
57
- history: this.storage.findByJob(name),
58
- metrics: this.storage.getMetrics(name),
59
- }));
53
+ const cron = [...this.schedulerRegistry.getCronJobs().entries()].map(([name, job]) => {
54
+ const nextRun = resolveNextRun(job);
55
+ return {
56
+ name,
57
+ cronExpression: resolveCronExpression(job.cronTime),
58
+ active: !scheduler_dash_context_1.SchedulerDashContext.disabledJobs.has(name),
59
+ running: job.running ?? false,
60
+ nextRun,
61
+ history: this.storage.findByJob(name),
62
+ metrics: this.storage.getMetrics(name),
63
+ };
64
+ });
60
65
  const intervals = this.schedulerRegistry.getIntervals().map((name) => ({ name }));
61
66
  const timeouts = this.schedulerRegistry.getTimeouts().map((name) => ({ name }));
62
67
  return { cron, intervals, timeouts };
@@ -65,11 +70,13 @@ let JobsService = class JobsService {
65
70
  const job = this.schedulerRegistry.getCronJobs().get(name);
66
71
  if (!job)
67
72
  return null;
73
+ const nextRun = resolveNextRun(job);
68
74
  return {
69
75
  name,
70
76
  cronExpression: resolveCronExpression(job.cronTime),
77
+ active: !scheduler_dash_context_1.SchedulerDashContext.disabledJobs.has(name),
71
78
  running: job.running ?? false,
72
- nextRun: resolveNextRun(job),
79
+ nextRun,
73
80
  history: this.storage.findByJob(name),
74
81
  metrics: this.storage.getMetrics(name),
75
82
  };