Remove old Calendar and Messaging partial/full sync stages (#15380)

Now that all existing and new workspaces have the following syncStage:
- CALENDAR_EVENT_LIST_FETCH_PENDING
- MESSAGE_LIST_FETCH_PENDING

We can fully deprecate the old FULL_CALENDAR_EVENT_LIST_FETCH_PENDING
and PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING (full vs partial is now
directly inferred from the presence of a cursor)
This commit is contained in:
Charles Bochet
2025-10-27 17:35:10 +01:00
committed by GitHub
parent 7e1c046e58
commit 6cf5bd2ed4
25 changed files with 42 additions and 110 deletions
@@ -49,7 +49,7 @@ export class BlocklistReimportCalendarEventsJob {
accountOwnerId: workspaceMemberId,
},
syncStage: Not(
CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING,
),
},
});
@@ -58,7 +58,7 @@ export class CalendarRelaunchFailedCalendarChannelsCommand extends ActiveOrSuspe
failedCalendarChannels.map(({ id }) => id),
{
syncStage:
CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING,
syncStatus: CalendarChannelSyncStatus.ACTIVE,
},
);
@@ -51,7 +51,7 @@ export class CalendarEventListFetchCronJob {
const schemaName = getWorkspaceSchemaName(activeWorkspace.id);
const calendarChannels = await this.coreDataSource.query(
`SELECT * FROM ${schemaName}."calendarChannel" WHERE "isSyncEnabled" = true AND "syncStage" IN ('${CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING}', '${CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING}')`,
`SELECT * FROM ${schemaName}."calendarChannel" WHERE "isSyncEnabled" = true AND "syncStage" IN ('${CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING}')`,
);
for (const calendarChannel of calendarChannels) {
@@ -58,8 +58,7 @@ export class CalendarEventListFetchJob {
switch (calendarChannel.syncStage) {
case CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_SCHEDULED:
case CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING: // DEPRECATED
case CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING: // WILL BE DEPRECATED
case CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING:
await this.calendarFetchEventsService.fetchCalendarEvents(
calendarChannel,
calendarChannel.connectedAccount,
@@ -18,8 +18,7 @@ import {
import { CalendarChannelSyncStatusService } from 'src/modules/calendar/common/services/calendar-channel-sync-status.service';
import { type CalendarChannelWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
export enum CalendarEventImportSyncStep {
FULL_CALENDAR_EVENT_LIST_FETCH = 'FULL_CALENDAR_EVENT_LIST_FETCH',
PARTIAL_CALENDAR_EVENT_LIST_FETCH = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH',
CALENDAR_EVENT_LIST_FETCH = 'CALENDAR_EVENT_LIST_FETCH',
CALENDAR_EVENTS_IMPORT = 'CALENDAR_EVENTS_IMPORT',
}
@@ -129,13 +128,7 @@ export class CalendarEventImportErrorHandlerService {
);
switch (syncStep) {
case CalendarEventImportSyncStep.FULL_CALENDAR_EVENT_LIST_FETCH:
await this.calendarChannelSyncStatusService.scheduleCalendarEventListFetch(
[calendarChannel.id],
);
break;
case CalendarEventImportSyncStep.PARTIAL_CALENDAR_EVENT_LIST_FETCH:
case CalendarEventImportSyncStep.CALENDAR_EVENT_LIST_FETCH:
await this.calendarChannelSyncStatusService.scheduleCalendarEventListFetch(
[calendarChannel.id],
);
@@ -199,9 +192,7 @@ export class CalendarEventImportErrorHandlerService {
calendarChannel: Pick<CalendarChannelWorkspaceEntity, 'id'>,
workspaceId: string,
): Promise<void> {
if (
syncStep === CalendarEventImportSyncStep.FULL_CALENDAR_EVENT_LIST_FETCH
) {
if (syncStep === CalendarEventImportSyncStep.CALENDAR_EVENT_LIST_FETCH) {
return;
}
@@ -16,10 +16,7 @@ import {
import { CalendarEventsImportService } from 'src/modules/calendar/calendar-event-import-manager/services/calendar-events-import.service';
import { CalendarGetCalendarEventsService } from 'src/modules/calendar/calendar-event-import-manager/services/calendar-get-events.service';
import { CalendarChannelSyncStatusService } from 'src/modules/calendar/common/services/calendar-channel-sync-status.service';
import {
CalendarChannelSyncStage,
type CalendarChannelWorkspaceEntity,
} from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
import { type CalendarChannelWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
import { type ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
@Injectable()
@@ -41,12 +38,6 @@ export class CalendarFetchEventsService {
connectedAccount: ConnectedAccountWorkspaceEntity,
workspaceId: string,
): Promise<void> {
const syncStep =
calendarChannel.syncStage ===
CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING
? CalendarEventImportSyncStep.FULL_CALENDAR_EVENT_LIST_FETCH
: CalendarEventImportSyncStep.PARTIAL_CALENDAR_EVENT_LIST_FETCH;
await this.calendarChannelSyncStatusService.markAsCalendarEventListFetchOngoing(
[calendarChannel.id],
);
@@ -142,7 +133,7 @@ export class CalendarFetchEventsService {
this.logger.error(error);
await this.calendarEventImportErrorHandlerService.handleDriverException(
error,
syncStep,
CalendarEventImportSyncStep.CALENDAR_EVENT_LIST_FETCH,
calendarChannel,
workspaceId,
);
@@ -38,8 +38,7 @@ export class CalendarChannelSyncStatusService {
);
await calendarChannelRepository.update(calendarChannelIds, {
syncStage:
CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
syncStage: CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING,
});
}
@@ -149,8 +148,7 @@ export class CalendarChannelSyncStatusService {
);
await calendarChannelRepository.update(calendarChannelIds, {
syncStage:
CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING,
syncStage: CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING,
syncStatus: CalendarChannelSyncStatus.ACTIVE,
throttleFailureCount: 0,
syncStageStartedAt: null,
@@ -36,8 +36,6 @@ export enum CalendarChannelSyncStatus {
export enum CalendarChannelSyncStage {
PENDING_CONFIGURATION = 'PENDING_CONFIGURATION',
FULL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'FULL_CALENDAR_EVENT_LIST_FETCH_PENDING', // WILL BE DEPRECATED
PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING', // DEPRECATED
CALENDAR_EVENT_LIST_FETCH_PENDING = 'CALENDAR_EVENT_LIST_FETCH_PENDING',
CALENDAR_EVENT_LIST_FETCH_SCHEDULED = 'CALENDAR_EVENT_LIST_FETCH_SCHEDULED',
CALENDAR_EVENT_LIST_FETCH_ONGOING = 'CALENDAR_EVENT_LIST_FETCH_ONGOING',
@@ -182,19 +180,6 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
position: 6,
color: 'red',
},
{
value: CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
label: 'Full calendar event list fetch pending',
position: 7,
color: 'blue',
},
{
value:
CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING,
label: 'Partial calendar event list fetch pending',
position: 8,
color: 'blue',
},
{
value: CalendarChannelSyncStage.PENDING_CONFIGURATION,
label: 'Pending configuration',
@@ -124,7 +124,7 @@ describe('ImapSmtpCalDavAPIService', () => {
handle: 'test@example.com',
isSyncEnabled: true,
syncStatus: MessageChannelSyncStatus.ONGOING,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
syncCursor: '',
syncStageStartedAt: null,
};
@@ -154,7 +154,7 @@ describe('ImapSmtpCalDavAPIService', () => {
handle: 'test@example.com',
isSyncEnabled: true,
syncStatus: MessageChannelSyncStatus.ONGOING,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
syncCursor: '',
syncStageStartedAt: null,
},
@@ -254,7 +254,7 @@ describe('ImapSmtpCalDavAPIService', () => {
handle: 'test@example.com',
isSyncEnabled: true,
syncStatus: MessageChannelSyncStatus.ONGOING,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
};
mockMessageChannelRepository.save.mockResolvedValue(
@@ -363,7 +363,7 @@ describe('ImapSmtpCalDavAPIService', () => {
handle: 'test@example.com',
isSyncEnabled: true,
syncStatus: MessageChannelSyncStatus.ONGOING,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
};
mockMessageChannelRepository.save.mockResolvedValue(
@@ -422,7 +422,7 @@ describe('ImapSmtpCalDavAPIService', () => {
handle: 'test@example.com',
isSyncEnabled: true,
syncStatus: MessageChannelSyncStatus.ONGOING,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
};
const expectedCalendarChannel = {
@@ -172,7 +172,7 @@ export class ImapSmtpCalDavAPIService {
? MessageChannelSyncStatus.ONGOING
: MessageChannelSyncStatus.NOT_SYNCED,
syncStage: shouldEnableSync
? MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING
? MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING
: undefined,
syncCursor: '',
syncStageStartedAt: null,
@@ -202,8 +202,7 @@ export class ImapSmtpCalDavAPIService {
handle: input.handle,
isSyncEnabled: shouldEnableSync,
syncStatus: CalendarChannelSyncStatus.ONGOING,
syncStage:
CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
syncStage: CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_PENDING,
syncCursor: '',
syncStageStartedAt: null,
},
@@ -48,9 +48,7 @@ export class BlocklistReimportMessagesJob {
connectedAccount: {
accountOwnerId: workspaceMemberId,
},
syncStage: Not(
MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
),
syncStage: Not(MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING),
},
});
@@ -38,7 +38,7 @@ export class MessageChannelSyncStatusService {
);
await messageChannelRepository.update(messageChannelIds, {
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
});
}
@@ -131,7 +131,7 @@ export class MessageChannelSyncStatusService {
await messageChannelRepository.update(messageChannelIds, {
syncStatus: MessageChannelSyncStatus.ACTIVE,
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
throttleFailureCount: 0,
syncStageStartedAt: null,
syncedAt: new Date().toISOString(),
@@ -32,8 +32,6 @@ export enum MessageChannelSyncStatus {
export enum MessageChannelSyncStage {
PENDING_CONFIGURATION = 'PENDING_CONFIGURATION',
FULL_MESSAGE_LIST_FETCH_PENDING = 'FULL_MESSAGE_LIST_FETCH_PENDING', // WILL BE DEPRECATED
PARTIAL_MESSAGE_LIST_FETCH_PENDING = 'PARTIAL_MESSAGE_LIST_FETCH_PENDING', // DEPRECATED
MESSAGE_LIST_FETCH_PENDING = 'MESSAGE_LIST_FETCH_PENDING',
MESSAGE_LIST_FETCH_SCHEDULED = 'MESSAGE_LIST_FETCH_SCHEDULED',
MESSAGE_LIST_FETCH_ONGOING = 'MESSAGE_LIST_FETCH_ONGOING',
@@ -419,22 +417,10 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
position: 6,
color: 'red',
},
{
value: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING, // WILL BE DEPRECATED
label: 'Full messages list fetch pending',
position: 7,
color: 'blue',
},
{
value: MessageChannelSyncStage.PARTIAL_MESSAGE_LIST_FETCH_PENDING, // DEPRECATED
label: 'Partial messages list fetch pending',
position: 8,
color: 'blue',
},
{
value: MessageChannelSyncStage.PENDING_CONFIGURATION,
label: 'Pending configuration',
position: 9,
position: 7,
color: 'gray',
},
],
@@ -57,7 +57,7 @@ export class MessagingRelaunchFailedMessageChannelsCommand extends ActiveOrSuspe
await messageChannelRepository.update(
failedMessageChannels.map(({ id }) => id),
{
syncStage: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
syncStatus: MessageChannelSyncStatus.ACTIVE,
},
);
@@ -48,9 +48,8 @@ export class MessagingMessageListFetchCronJob {
try {
const schemaName = getWorkspaceSchemaName(activeWorkspace.id);
// TODO: deprecate looking for FULL_MESSAGE_LIST_FETCH_PENDING as we introduce MESSAGE_LIST_FETCH_PENDING
const messageChannels = await this.coreDataSource.query(
`SELECT * FROM ${schemaName}."messageChannel" WHERE "isSyncEnabled" = true AND "syncStage" IN ('${MessageChannelSyncStage.PARTIAL_MESSAGE_LIST_FETCH_PENDING}', '${MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING}')`,
`SELECT * FROM ${schemaName}."messageChannel" WHERE "isSyncEnabled" = true AND "syncStage" IN ('${MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING}')`,
);
for (const messageChannel of messageChannels) {
@@ -77,10 +77,8 @@ export class MessagingMessageListFetchJob {
switch (messageChannel.syncStage) {
case MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING:
case MessageChannelSyncStage.PARTIAL_MESSAGE_LIST_FETCH_PENDING: // DEPRECATED
case MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING: // WILL BE DEPRECATED
await this.messagingMonitoringService.track({
eventName: 'full_message_list_fetch.started',
eventName: 'message_list_fetch.started',
workspaceId,
connectedAccountId: messageChannel.connectedAccount.id,
messageChannelId: messageChannel.id,
@@ -92,7 +90,7 @@ export class MessagingMessageListFetchJob {
);
await this.messagingMonitoringService.track({
eventName: 'full_message_list_fetch.completed',
eventName: 'message_list_fetch.completed',
workspaceId,
connectedAccountId: messageChannel.connectedAccount.id,
messageChannelId: messageChannel.id,
@@ -194,7 +194,7 @@ describe('MessagingMessagesImportService', () => {
it('should fails if SyncStage is not MESSAGES_IMPORT_PENDING', async () => {
mockMessageChannel.syncStage =
MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING;
MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING;
expect(
service.processMessageBatchImport(