mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-27 22:32:49 +03:00
6687 change messaging import cron job to run every minute (#6704)
Closes #6687
This commit is contained in:
parent
9898ca3e53
commit
579c2ebcea
@ -5,6 +5,8 @@ import { MessageQueue } from 'src/engine/integrations/message-queue/message-queu
|
||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||
import { MessagingMessagesImportCronJob } from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-messages-import.cron.job';
|
||||
|
||||
const MESSAGING_MESSAGES_IMPORT_CRON_PATTERN = '*/1 * * * *';
|
||||
|
||||
@Command({
|
||||
name: 'cron:messaging:messages-import',
|
||||
description: 'Starts a cron job to fetch all messages from cache',
|
||||
@ -23,7 +25,7 @@ export class MessagingMessagesImportCronCommand extends CommandRunner {
|
||||
undefined,
|
||||
{
|
||||
repeat: {
|
||||
every: 30000,
|
||||
pattern: MESSAGING_MESSAGES_IMPORT_CRON_PATTERN,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
@ -24,8 +23,6 @@ import {
|
||||
|
||||
@Processor(MessageQueue.cronQueue)
|
||||
export class MessagingMessagesImportCronJob {
|
||||
private readonly logger = new Logger(MessagingMessagesImportCronJob.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(Workspace, 'core')
|
||||
private readonly workspaceRepository: Repository<Workspace>,
|
||||
@ -51,23 +48,20 @@ export class MessagingMessagesImportCronJob {
|
||||
);
|
||||
|
||||
const messageChannels = await messageChannelRepository.find({
|
||||
select: ['id', 'isSyncEnabled', 'syncStage'],
|
||||
where: {
|
||||
isSyncEnabled: true,
|
||||
syncStage: MessageChannelSyncStage.MESSAGES_IMPORT_PENDING,
|
||||
},
|
||||
});
|
||||
|
||||
for (const messageChannel of messageChannels) {
|
||||
if (
|
||||
messageChannel.isSyncEnabled &&
|
||||
messageChannel.syncStage ===
|
||||
MessageChannelSyncStage.MESSAGES_IMPORT_PENDING
|
||||
) {
|
||||
await this.messageQueueService.add<MessagingMessagesImportJobData>(
|
||||
MessagingMessagesImportJob.name,
|
||||
{
|
||||
workspaceId: activeWorkspace.id,
|
||||
messageChannelId: messageChannel.id,
|
||||
},
|
||||
);
|
||||
}
|
||||
await this.messageQueueService.add<MessagingMessagesImportJobData>(
|
||||
MessagingMessagesImportJob.name,
|
||||
{
|
||||
workspaceId: activeWorkspace.id,
|
||||
messageChannelId: messageChannel.id,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
export const MESSAGING_GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 100;
|
||||
export const MESSAGING_GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 200;
|
||||
|
Loading…
Reference in New Issue
Block a user