Seed calendar events (#4967)
Added seeds for: - `calendar-event-participants` - `calendar-channel` - `calendar-channel-event-association`
This commit is contained in:
@ -11,7 +11,6 @@ import { seedCoreSchema } from 'src/database/typeorm-seeds/core';
|
||||
import { ObjectMetadataService } from 'src/engine/metadata-modules/object-metadata/object-metadata.service';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service';
|
||||
import { seedCalendarEvents } from 'src/database/typeorm-seeds/workspace/calendar-events';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
import {
|
||||
SEED_APPLE_WORKSPACE_ID,
|
||||
@ -24,6 +23,10 @@ import { seedMessageChannelMessageAssociation } from 'src/database/typeorm-seeds
|
||||
import { seedMessageParticipant } from 'src/database/typeorm-seeds/workspace/message-participants';
|
||||
import { seedMessageThread } from 'src/database/typeorm-seeds/workspace/message-threads';
|
||||
import { viewPrefillData } from 'src/engine/workspace-manager/standard-objects-prefill-data/view';
|
||||
import { seedCalendarEvents } from 'src/database/typeorm-seeds/workspace/calendar-events';
|
||||
import { seedCalendarChannels } from 'src/database/typeorm-seeds/workspace/calendar-channel';
|
||||
import { seedCalendarChannelEventAssociations } from 'src/database/typeorm-seeds/workspace/calendar-channel-event-association';
|
||||
import { seedCalendarEventParticipants } from 'src/database/typeorm-seeds/workspace/calendar-event-participants';
|
||||
|
||||
// TODO: implement dry-run
|
||||
@Command({
|
||||
@ -117,7 +120,6 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
|
||||
await seedCompanies(entityManager, dataSourceMetadata.schema);
|
||||
await seedPeople(entityManager, dataSourceMetadata.schema);
|
||||
await seedOpportunity(entityManager, dataSourceMetadata.schema);
|
||||
await seedCalendarEvents(entityManager, dataSourceMetadata.schema);
|
||||
await seedWorkspaceMember(
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
@ -143,6 +145,23 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
);
|
||||
|
||||
await seedCalendarEvents(
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
);
|
||||
await seedCalendarChannels(
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
);
|
||||
await seedCalendarChannelEventAssociations(
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
);
|
||||
await seedCalendarEventParticipants(
|
||||
entityManager,
|
||||
dataSourceMetadata.schema,
|
||||
);
|
||||
}
|
||||
|
||||
await viewPrefillData(
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
const tableName = 'calendarChannelEventAssociation';
|
||||
|
||||
export const seedCalendarChannelEventAssociations = async (
|
||||
entityManager: EntityManager,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await entityManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'calendarChannelId',
|
||||
'calendarEventId',
|
||||
'eventExternalId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: 'e1ab9e1b-df6e-438e-a788-11c96dcecdd3',
|
||||
calendarChannelId: '59efdefe-a40f-4faf-bb9f-c6f9945b8203',
|
||||
calendarEventId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
eventExternalId: 'exampleExternalId',
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
import { DEV_SEED_CONNECTED_ACCOUNT_IDS } from 'src/database/typeorm-seeds/workspace/connected-account';
|
||||
|
||||
const tableName = 'calendarChannel';
|
||||
|
||||
export const seedCalendarChannels = async (
|
||||
entityManager: EntityManager,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await entityManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'connectedAccountId',
|
||||
'handle',
|
||||
'visibility',
|
||||
'isContactAutoCreationEnabled',
|
||||
'isSyncEnabled',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: '59efdefe-a40f-4faf-bb9f-c6f9945b8203',
|
||||
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.TIM,
|
||||
handle: 'tim@apple.com',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
isContactAutoCreationEnabled: true,
|
||||
isSyncEnabled: true,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,50 @@
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
import { DEV_SEED_PERSON_IDS } from 'src/database/typeorm-seeds/workspace/people';
|
||||
import { DEV_SEED_WORKSPACE_MEMBER_IDS } from 'src/database/typeorm-seeds/workspace/workspace-members';
|
||||
import { CalendarEventParticipantResponseStatus } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
|
||||
|
||||
const tableName = 'calendarEventParticipant';
|
||||
|
||||
export const seedCalendarEventParticipants = async (
|
||||
entityManager: EntityManager,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await entityManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'calendarEventId',
|
||||
'handle',
|
||||
'displayName',
|
||||
'isOrganizer',
|
||||
'responseStatus',
|
||||
'personId',
|
||||
'workspaceMemberId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: 'da8f47c3-8055-49ad-b7e4-9c9d5bbc1ecc',
|
||||
calendarEventId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
handle: 'christoph.calisto@linkedin.com',
|
||||
displayName: 'Christoph Calisto',
|
||||
isOrganizer: true,
|
||||
responseStatus: CalendarEventParticipantResponseStatus.ACCEPTED,
|
||||
personId: DEV_SEED_PERSON_IDS.CHRISTOPH,
|
||||
workspaceMemberId: null,
|
||||
},
|
||||
{
|
||||
id: 'e1ab9e1b-df6e-438e-a788-11c96dcecdd3',
|
||||
calendarEventId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
handle: 'tim@apple.com',
|
||||
displayName: 'Tim Apple',
|
||||
isOrganizer: false,
|
||||
responseStatus: CalendarEventParticipantResponseStatus.ACCEPTED,
|
||||
personId: null,
|
||||
workspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
Reference in New Issue
Block a user