Create new sync statuses and stages for calendar (#5997)

Create fields:
- syncStatus
- syncStage
- syncStageStartedAt
This commit is contained in:
bosiraphael 2024-06-24 16:39:56 +02:00 committed by GitHub
parent ad61efe6ed
commit f3701281e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 122 additions and 0 deletions

View File

@ -71,6 +71,9 @@ export const CALENDAR_CHANNEL_STANDARD_FIELD_IDS = {
syncCursor: '20202020-bac2-4852-a5cb-7a7898992b70',
calendarChannelEventAssociations: '20202020-afb0-4a9f-979f-2d5087d71d09',
throttleFailureCount: '20202020-525c-4b76-b9bd-0dd57fd11d61',
syncStatus: '20202020-7116-41da-8b4b-035975c4eb6a',
syncStage: '20202020-6246-42e6-b5cd-003bd921782c',
syncStageStartedAt: '20202020-a934-46f1-a8e7-9568b1e3a53e',
};
export const CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS = {

View File

@ -15,12 +15,30 @@ import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
export enum CalendarChannelVisibility {
METADATA = 'METADATA',
SHARE_EVERYTHING = 'SHARE_EVERYTHING',
}
export enum CalendarChannelSyncStatus {
NOT_SYNCED = 'NOT_SYNCED',
ONGOING = 'ONGOING',
ACTIVE = 'ACTIVE',
FAILED_INSUFFICIENT_PERMISSIONS = 'FAILED_INSUFFICIENT_PERMISSIONS',
FAILED_UNKNOWN = 'FAILED_UNKNOWN',
}
export enum CalendarChannelSyncStage {
FULL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'FULL_CALENDAR_EVENT_LIST_FETCH_PENDING',
PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING',
CALENDAR_EVENT_LIST_FETCH_ONGOING = 'CALENDAR_EVENT_LIST_FETCH_ONGOING',
CALENDAR_EVENTS_IMPORT_PENDING = 'CALENDAR_EVENTS_IMPORT_PENDING',
CALENDAR_EVENTS_IMPORT_ONGOING = 'CALENDAR_EVENTS_IMPORT_ONGOING',
FAILED = 'FAILED',
}
@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.calendarChannel,
namePlural: 'calendarChannels',
@ -41,6 +59,97 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
})
handle: string;
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStatus,
type: FieldMetadataType.SELECT,
label: 'Sync status',
description: 'Sync status',
icon: 'IconStatusChange',
options: [
{
value: CalendarChannelSyncStatus.ONGOING,
label: 'Ongoing',
position: 1,
color: 'yellow',
},
{
value: CalendarChannelSyncStatus.NOT_SYNCED,
label: 'Not Synced',
position: 2,
color: 'blue',
},
{
value: CalendarChannelSyncStatus.ACTIVE,
label: 'Active',
position: 3,
color: 'green',
},
{
value: CalendarChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS,
label: 'Failed Insufficient Permissions',
position: 4,
color: 'red',
},
{
value: CalendarChannelSyncStatus.FAILED_UNKNOWN,
label: 'Failed Unknown',
position: 5,
color: 'red',
},
],
})
@WorkspaceIsNullable()
syncStatus: CalendarChannelSyncStatus | null;
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStage,
type: FieldMetadataType.SELECT,
label: 'Sync stage',
description: 'Sync stage',
icon: 'IconStatusChange',
options: [
{
value: CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
label: 'Full calendar event list fetch pending',
position: 0,
color: 'blue',
},
{
value:
CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING,
label: 'Partial calendar event list fetch pending',
position: 1,
color: 'blue',
},
{
value: CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_ONGOING,
label: 'Calendar event list fetch ongoing',
position: 2,
color: 'orange',
},
{
value: CalendarChannelSyncStage.CALENDAR_EVENTS_IMPORT_PENDING,
label: 'Calendar events import pending',
position: 3,
color: 'blue',
},
{
value: CalendarChannelSyncStage.CALENDAR_EVENTS_IMPORT_ONGOING,
label: 'Calendar events import ongoing',
position: 4,
color: 'orange',
},
{
value: CalendarChannelSyncStage.FAILED,
label: 'Failed',
position: 5,
color: 'red',
},
],
defaultValue: `'${CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING}'`,
})
syncStage: CalendarChannelSyncStage;
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.visibility,
type: FieldMetadataType.SELECT,
@ -96,6 +205,16 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
})
syncCursor: string;
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStageStartedAt,
type: FieldMetadataType.DATE_TIME,
label: 'Sync stage started at',
description: 'Sync stage started at',
icon: 'IconHistory',
})
@WorkspaceIsNullable()
syncStageStartedAt: string | null;
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.throttleFailureCount,
type: FieldMetadataType.NUMBER,