5617 Create CalendarOngoingStaleCron Job (#6748)

Closes #5617

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Raphaël Bosi
2024-08-27 19:13:15 +02:00
committed by GitHub
parent e771793626
commit e6a55f270b
9 changed files with 214 additions and 0 deletions

View File

@ -93,6 +93,20 @@ export class MessageChannelSyncStatusService {
await this.scheduleFullMessageListFetch(messageChannelId);
}
public async resetSyncStageStartedAt(messageChannelId: string) {
const messageChannelRepository =
await this.twentyORMManager.getRepository<MessageChannelWorkspaceEntity>(
'messageChannel',
);
await messageChannelRepository.update(
{ id: messageChannelId },
{
syncStageStartedAt: null,
},
);
}
public async markAsMessagesListFetchOngoing(messageChannelId: string) {
const messageChannelRepository =
await this.twentyORMManager.getRepository<MessageChannelWorkspaceEntity>(

View File

@ -55,6 +55,10 @@ export class MessagingOngoingStaleJob {
`Sync for message channel ${messageChannel.id} and workspace ${workspaceId} is stale. Setting sync stage to MESSAGES_IMPORT_PENDING`,
);
await this.messagingChannelSyncStatusService.resetSyncStageStartedAt(
messageChannel.id,
);
switch (messageChannel.syncStage) {
case MessageChannelSyncStage.MESSAGE_LIST_FETCH_ONGOING:
await this.messageChannelSyncStatusService.schedulePartialMessageListFetch(