Skip to content

Commit c8d2fb0

Browse files
committed
fix: remove schedule on bootstrap
1 parent 5c580af commit c8d2fb0

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

src/modules/jobs/tasks/hard-delete-old-files/hard-delete-old-files.scheduler.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ describe('HardDeleteOldFilesScheduler', () => {
4040
expect(scheduler).toBeDefined();
4141
});
4242

43-
describe('onApplicationBootstrap', () => {
44-
it('When called, then it should invoke scheduleCleanup', async () => {
45-
jest.spyOn(scheduler, 'scheduleCleanup').mockResolvedValue();
46-
47-
await scheduler.onApplicationBootstrap();
48-
49-
expect(scheduler.scheduleCleanup).toHaveBeenCalledTimes(1);
50-
});
51-
});
52-
5343
describe('scheduleCleanup', () => {
5444
it('When called, then it should enqueue a job with the correct job name', async () => {
5545
await scheduler.scheduleCleanup();

src/modules/jobs/tasks/hard-delete-old-files/hard-delete-old-files.scheduler.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
import {
2-
type OnApplicationBootstrap,
3-
Injectable,
4-
Logger,
5-
} from '@nestjs/common';
1+
import { Injectable, Logger } from '@nestjs/common';
62
import { InjectQueue } from '@nestjs/bullmq';
73
import { Queue } from 'bullmq';
84
import { Cron, CronExpression } from '@nestjs/schedule';
95
import { JobName } from '../../constants';
106

117
export const HARD_DELETE_OLD_FILES_QUEUE = 'hard-delete-old-files';
12-
export const HARD_DELETE_OLD_FILES_JOB_ID = 'hard-delete-old-files:run';
8+
export const HARD_DELETE_OLD_FILES_JOB_ID = 'hard-delete-old-files-id';
139

1410
@Injectable()
15-
export class HardDeleteOldFilesScheduler implements OnApplicationBootstrap {
11+
export class HardDeleteOldFilesScheduler {
1612
private readonly logger = new Logger(JobName.HARD_DELETE_OLD_DELETED_FILES);
1713

1814
constructor(
1915
@InjectQueue(HARD_DELETE_OLD_FILES_QUEUE) private readonly queue: Queue,
2016
) {}
2117

22-
async onApplicationBootstrap() {
23-
await this.scheduleCleanup();
24-
}
25-
2618
@Cron(CronExpression.EVERY_HOUR, {
2719
name: JobName.HARD_DELETE_OLD_DELETED_FILES,
2820
})

0 commit comments

Comments
 (0)