@ -1,4 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository, In } from 'typeorm';
|
||||
@ -16,8 +16,6 @@ import { GmailFetchMessageContentFromCacheService } from 'src/modules/messaging/
|
||||
export class FetchAllMessagesFromCacheCronJob
|
||||
implements MessageQueueJob<undefined>
|
||||
{
|
||||
private readonly logger = new Logger(FetchAllMessagesFromCacheCronJob.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(Workspace, 'core')
|
||||
private readonly workspaceRepository: Repository<Workspace>,
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
import { Command, CommandRunner } from 'nest-commander';
|
||||
|
||||
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||
import { FetchAllMessagesFromCacheCronJob } from 'src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job';
|
||||
|
||||
@Command({
|
||||
name: 'cron:messaging:gmail-fetch-messages-from-cache',
|
||||
description: 'Starts a cron job to fetch all messages from cache',
|
||||
})
|
||||
export class GmailFetchMessagesFromCacheCronCommand extends CommandRunner {
|
||||
constructor(
|
||||
@Inject(MessageQueue.cronQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
await this.messageQueueService.addCron<undefined>(
|
||||
FetchAllMessagesFromCacheCronJob.name,
|
||||
undefined,
|
||||
{
|
||||
repeat: {
|
||||
every: 5000,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
import { Command, CommandRunner } from 'nest-commander';
|
||||
|
||||
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||
import { GmailPartialSyncCronJob } from 'src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job';
|
||||
import { fetchAllWorkspacesMessagesCronPattern } from 'src/modules/messaging/jobs/crons/patterns/fetch-all-workspaces-messages.cron.pattern';
|
||||
|
||||
@Command({
|
||||
name: 'cron:messaging:gmail-partial-sync',
|
||||
description:
|
||||
'Starts a cron job to sync existing connected account messages and store them in the cache',
|
||||
})
|
||||
export class GmailPartialSyncCronCommand extends CommandRunner {
|
||||
constructor(
|
||||
@Inject(MessageQueue.cronQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
await this.messageQueueService.addCron<undefined>(
|
||||
GmailPartialSyncCronJob.name,
|
||||
undefined,
|
||||
{
|
||||
repeat: { pattern: fetchAllWorkspacesMessagesCronPattern },
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
export const fetchAllWorkspacesMessagesCronPattern = '*/5 * * * *';
|
||||
Reference in New Issue
Block a user