Add command to stop demo seed cron (#4480)

Rename start cron + add stop cron

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-03-15 15:23:07 +01:00
committed by GitHub
parent 7555e7aad5
commit 21cd38d6fb
3 changed files with 35 additions and 5 deletions

View File

@ -8,10 +8,10 @@ import { MessageQueue } from 'src/integrations/message-queue/message-queue.const
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
@Command({
name: 'workspace:cron:seed:demo',
description: 'Seed workspace with demo data.',
name: 'workspace-seed-demo:cron:start',
description: 'Start cron to seed workspace with demo data.',
})
export class DataSeedDemoWorkspaceCronCommand extends CommandRunner {
export class StartDataSeedDemoWorkspaceCronCommand extends CommandRunner {
constructor(
@Inject(MessageQueue.cronQueue)
private readonly messageQueueService: MessageQueueService,

View File

@ -0,0 +1,28 @@
import { Inject } from '@nestjs/common';
import { Command, CommandRunner } from 'nest-commander';
import { dataSeedDemoWorkspaceCronPattern } from 'src/database/commands/data-seed-demo-workspace/crons/data-seed-demo-workspace-cron-pattern';
import { DataSeedDemoWorkspaceJob } from 'src/database/commands/data-seed-demo-workspace/jobs/data-seed-demo-workspace.job';
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
@Command({
name: 'workspace-seed-demo:cron:stop',
description: 'Stop cron to seed workspace with demo data.',
})
export class StopDataSeedDemoWorkspaceCronCommand extends CommandRunner {
constructor(
@Inject(MessageQueue.cronQueue)
private readonly messageQueueService: MessageQueueService,
) {
super();
}
async run(): Promise<void> {
await this.messageQueueService.removeCron(
DataSeedDemoWorkspaceJob.name,
dataSeedDemoWorkspaceCronPattern,
);
}
}