Skip to content

Commit

Permalink
Seed calendar events (#4967)
Browse files Browse the repository at this point in the history
Added seeds for: 
- `calendar-event-participants`
- `calendar-channel`
- `calendar-channel-event-association`
  • Loading branch information
bosiraphael authored Apr 15, 2024
1 parent 764a3eb commit 11d928b
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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({
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
};
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
visibility: 'SHARE_EVERYTHING',
isContactAutoCreationEnabled: true,
isSyncEnabled: true,
},
])
.execute();
};
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
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: '[email protected]',
displayName: 'Tim Apple',
isOrganizer: false,
responseStatus: CalendarEventParticipantResponseStatus.ACCEPTED,
personId: null,
workspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
},
])
.execute();
};

0 comments on commit 11d928b

Please sign in to comment.