4702 rename calendareventattendee to calendareventparticipant (#4761)
Closes #4702
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { ObjectType, Field, ID } from '@nestjs/graphql';
|
||||
|
||||
@ObjectType('TimelineCalendarEventAttendee')
|
||||
export class TimelineCalendarEventAttendee {
|
||||
@ObjectType('TimelineCalendarEventParticipant')
|
||||
export class TimelineCalendarEventParticipant {
|
||||
@Field(() => ID, { nullable: true })
|
||||
personId: string;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ObjectType, ID, Field, registerEnumType } from '@nestjs/graphql';
|
||||
|
||||
import { TimelineCalendarEventAttendee } from 'src/engine/core-modules/calendar/dtos/timeline-calendar-event-attendee.dto';
|
||||
import { TimelineCalendarEventParticipant } from 'src/engine/core-modules/calendar/dtos/timeline-calendar-event-participant.dto';
|
||||
|
||||
export enum TimelineCalendarEventVisibility {
|
||||
METADATA = 'METADATA',
|
||||
@ -53,8 +53,8 @@ export class TimelineCalendarEvent {
|
||||
@Field(() => LinkMetadata)
|
||||
conferenceLink: LinkMetadata;
|
||||
|
||||
@Field(() => [TimelineCalendarEventAttendee])
|
||||
attendees: TimelineCalendarEventAttendee[];
|
||||
@Field(() => [TimelineCalendarEventParticipant])
|
||||
participants: TimelineCalendarEventParticipant[];
|
||||
|
||||
@Field(() => TimelineCalendarEventVisibility)
|
||||
visibility: TimelineCalendarEventVisibility;
|
||||
|
||||
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import groupBy from 'lodash.groupby';
|
||||
|
||||
import { TIMELINE_CALENDAR_EVENTS_DEFAULT_PAGE_SIZE } from 'src/engine/core-modules/calendar/constants/calendar.constants';
|
||||
import { TimelineCalendarEventAttendee } from 'src/engine/core-modules/calendar/dtos/timeline-calendar-event-attendee.dto';
|
||||
import { TimelineCalendarEventParticipant } from 'src/engine/core-modules/calendar/dtos/timeline-calendar-event-participant.dto';
|
||||
import {
|
||||
TimelineCalendarEvent,
|
||||
TimelineCalendarEventVisibility,
|
||||
@ -11,10 +11,10 @@ import {
|
||||
import { TimelineCalendarEventsWithTotal } from 'src/engine/core-modules/calendar/dtos/timeline-calendar-events-with-total.dto';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
|
||||
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
|
||||
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
|
||||
|
||||
type TimelineCalendarEventAttendeeWithPersonInformation =
|
||||
ObjectRecord<CalendarEventAttendeeObjectMetadata> & {
|
||||
type TimelineCalendarEventParticipantWithPersonInformation =
|
||||
ObjectRecord<CalendarEventParticipantObjectMetadata> & {
|
||||
personFirstName: string;
|
||||
personLastName: string;
|
||||
personAvatarUrl: string;
|
||||
@ -40,18 +40,18 @@ export class TimelineCalendarEventService {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const calendarEvents: Omit<TimelineCalendarEvent, 'attendees'>[] =
|
||||
const calendarEvents: Omit<TimelineCalendarEvent, 'participants'>[] =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT
|
||||
"calendarEvent".*
|
||||
FROM
|
||||
${dataSourceSchema}."calendarEvent" "calendarEvent"
|
||||
LEFT JOIN
|
||||
${dataSourceSchema}."calendarEventAttendee" "calendarEventAttendee" ON "calendarEvent".id = "calendarEventAttendee"."calendarEventId"
|
||||
${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant" ON "calendarEvent".id = "calendarEventParticipant"."calendarEventId"
|
||||
LEFT JOIN
|
||||
${dataSourceSchema}."person" "person" ON "calendarEventAttendee"."personId" = "person".id
|
||||
${dataSourceSchema}."person" "person" ON "calendarEventParticipant"."personId" = "person".id
|
||||
WHERE
|
||||
"calendarEventAttendee"."personId" = ANY($1)
|
||||
"calendarEventParticipant"."personId" = ANY($1)
|
||||
GROUP BY
|
||||
"calendarEvent".id
|
||||
ORDER BY
|
||||
@ -69,10 +69,10 @@ export class TimelineCalendarEventService {
|
||||
};
|
||||
}
|
||||
|
||||
const calendarEventAttendees: TimelineCalendarEventAttendeeWithPersonInformation[] =
|
||||
const calendarEventParticipants: TimelineCalendarEventParticipantWithPersonInformation[] =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT
|
||||
"calendarEventAttendee".*,
|
||||
"calendarEventParticipant".*,
|
||||
"person"."nameFirstName" as "personFirstName",
|
||||
"person"."nameLastName" as "personLastName",
|
||||
"person"."avatarUrl" as "personAvatarUrl",
|
||||
@ -80,46 +80,52 @@ export class TimelineCalendarEventService {
|
||||
"workspaceMember"."nameLastName" as "workspaceMemberLastName",
|
||||
"workspaceMember"."avatarUrl" as "workspaceMemberAvatarUrl"
|
||||
FROM
|
||||
${dataSourceSchema}."calendarEventAttendee" "calendarEventAttendee"
|
||||
${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant"
|
||||
LEFT JOIN
|
||||
${dataSourceSchema}."person" "person" ON "calendarEventAttendee"."personId" = "person".id
|
||||
${dataSourceSchema}."person" "person" ON "calendarEventParticipant"."personId" = "person".id
|
||||
LEFT JOIN
|
||||
${dataSourceSchema}."workspaceMember" "workspaceMember" ON "calendarEventAttendee"."workspaceMemberId" = "workspaceMember".id
|
||||
${dataSourceSchema}."workspaceMember" "workspaceMember" ON "calendarEventParticipant"."workspaceMemberId" = "workspaceMember".id
|
||||
WHERE
|
||||
"calendarEventAttendee"."calendarEventId" = ANY($1)`,
|
||||
"calendarEventParticipant"."calendarEventId" = ANY($1)`,
|
||||
[calendarEvents.map((event) => event.id)],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const formattedCalendarEventAttendees: TimelineCalendarEventAttendee[] =
|
||||
calendarEventAttendees.map((attendee) => {
|
||||
const formattedCalendarEventParticipants: TimelineCalendarEventParticipant[] =
|
||||
calendarEventParticipants.map((participant) => {
|
||||
const firstName =
|
||||
attendee.personFirstName || attendee.workspaceMemberFirstName || '';
|
||||
participant.personFirstName ||
|
||||
participant.workspaceMemberFirstName ||
|
||||
'';
|
||||
|
||||
const lastName =
|
||||
attendee.personLastName || attendee.workspaceMemberLastName || '';
|
||||
participant.personLastName ||
|
||||
participant.workspaceMemberLastName ||
|
||||
'';
|
||||
|
||||
const displayName =
|
||||
firstName || attendee.displayName || attendee.handle;
|
||||
firstName || participant.displayName || participant.handle;
|
||||
|
||||
const avatarUrl =
|
||||
attendee.personAvatarUrl || attendee.workspaceMemberAvatarUrl || '';
|
||||
participant.personAvatarUrl ||
|
||||
participant.workspaceMemberAvatarUrl ||
|
||||
'';
|
||||
|
||||
return {
|
||||
calendarEventId: attendee.calendarEventId,
|
||||
personId: attendee.personId,
|
||||
workspaceMemberId: attendee.workspaceMemberId,
|
||||
calendarEventId: participant.calendarEventId,
|
||||
personId: participant.personId,
|
||||
workspaceMemberId: participant.workspaceMemberId,
|
||||
firstName,
|
||||
lastName,
|
||||
displayName,
|
||||
avatarUrl,
|
||||
handle: attendee.handle,
|
||||
handle: participant.handle,
|
||||
};
|
||||
});
|
||||
|
||||
const calendarEventAttendeesByEventId: {
|
||||
[calendarEventId: string]: TimelineCalendarEventAttendee[];
|
||||
} = groupBy(formattedCalendarEventAttendees, 'calendarEventId');
|
||||
const calendarEventParticipantsByEventId: {
|
||||
[calendarEventId: string]: TimelineCalendarEventParticipant[];
|
||||
} = groupBy(formattedCalendarEventParticipants, 'calendarEventId');
|
||||
|
||||
const totalNumberOfCalendarEvents: { count: number }[] =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
@ -127,46 +133,46 @@ export class TimelineCalendarEventService {
|
||||
SELECT
|
||||
COUNT(DISTINCT "calendarEventId")
|
||||
FROM
|
||||
${dataSourceSchema}."calendarEventAttendee" "calendarEventAttendee"
|
||||
${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant"
|
||||
WHERE
|
||||
"calendarEventAttendee"."personId" = ANY($1)
|
||||
"calendarEventParticipant"."personId" = ANY($1)
|
||||
`,
|
||||
[personIds],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const timelineCalendarEvents = calendarEvents.map((event) => {
|
||||
const attendees = calendarEventAttendeesByEventId[event.id] || [];
|
||||
const participants = calendarEventParticipantsByEventId[event.id] || [];
|
||||
|
||||
return {
|
||||
...event,
|
||||
attendees,
|
||||
participants,
|
||||
};
|
||||
});
|
||||
|
||||
const calendarEventIdsWithWorkspaceMemberInAttendees =
|
||||
const calendarEventIdsWithWorkspaceMemberInParticipants =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`
|
||||
SELECT
|
||||
"calendarEventId"
|
||||
FROM
|
||||
${dataSourceSchema}."calendarEventAttendee" "calendarEventAttendee"
|
||||
${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant"
|
||||
WHERE
|
||||
"calendarEventAttendee"."workspaceMemberId" = $1
|
||||
"calendarEventParticipant"."workspaceMemberId" = $1
|
||||
`,
|
||||
[workspaceMemberId],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const calendarEventIdsWithWorkspaceMemberInAttendeesFormatted =
|
||||
calendarEventIdsWithWorkspaceMemberInAttendees.map(
|
||||
const calendarEventIdsWithWorkspaceMemberInParticipantsFormatted =
|
||||
calendarEventIdsWithWorkspaceMemberInParticipants.map(
|
||||
(event: { calendarEventId: string }) => event.calendarEventId,
|
||||
);
|
||||
|
||||
const calendarEventIdsToFetchVisibilityFor = timelineCalendarEvents
|
||||
.filter(
|
||||
(event) =>
|
||||
!calendarEventIdsWithWorkspaceMemberInAttendeesFormatted.includes(
|
||||
!calendarEventIdsWithWorkspaceMemberInParticipantsFormatted.includes(
|
||||
event.id,
|
||||
),
|
||||
)
|
||||
|
||||
@ -37,7 +37,6 @@ export enum FieldMetadataType {
|
||||
RELATION = 'RELATION',
|
||||
POSITION = 'POSITION',
|
||||
ADDRESS = 'ADDRESS',
|
||||
JSON = 'JSON',
|
||||
RAW_JSON = 'RAW_JSON',
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CalendarChannelEventAssociationRepository } from 'src/modules/calendar/repositories/calendar-channel-event-association.repository';
|
||||
import { CalendarChannelRepository } from 'src/modules/calendar/repositories/calendar-channel.repository';
|
||||
import { CalendarEventAttendeeRepository } from 'src/modules/calendar/repositories/calendar-event-attendee.repository';
|
||||
import { CalendarEventParticipantRepository } from 'src/modules/calendar/repositories/calendar-event-participant.repository';
|
||||
import { CalendarEventRepository } from 'src/modules/calendar/repositories/calendar-event.repository';
|
||||
import { CompanyRepository } from 'src/modules/company/repositories/company.repository';
|
||||
import { BlocklistRepository } from 'src/modules/connected-account/repositories/blocklist.repository';
|
||||
@ -19,7 +19,7 @@ export const metadataToRepositoryMapping = {
|
||||
CalendarChannelEventAssociationObjectMetadata:
|
||||
CalendarChannelEventAssociationRepository,
|
||||
CalendarChannelObjectMetadata: CalendarChannelRepository,
|
||||
CalendarEventAttendeeObjectMetadata: CalendarEventAttendeeRepository,
|
||||
CalendarEventParticipantObjectMetadata: CalendarEventParticipantRepository,
|
||||
CalendarEventObjectMetadata: CalendarEventRepository,
|
||||
CompanyObjectMetadata: CompanyRepository,
|
||||
ConnectedAccountObjectMetadata: ConnectedAccountRepository,
|
||||
|
||||
@ -72,7 +72,7 @@ export const calendarChannelStandardFieldIds = {
|
||||
calendarChannelEventAssociations: '20202020-afb0-4a9f-979f-2d5087d71d09',
|
||||
};
|
||||
|
||||
export const calendarEventAttendeeStandardFieldIds = {
|
||||
export const calendarEventParticipantStandardFieldIds = {
|
||||
calendarEvent: '20202020-fe3a-401c-b889-af4f4657a861',
|
||||
handle: '20202020-8692-4580-8210-9e09cbd031a7',
|
||||
displayName: '20202020-ee1e-4f9f-8ac1-5c0b2f69691e',
|
||||
@ -97,7 +97,7 @@ export const calendarEventStandardFieldIds = {
|
||||
conferenceLink: '20202020-35da-43ef-9ca0-e936e9dc237b',
|
||||
recurringEventExternalId: '20202020-4b96-43d0-8156-4c7a9717635c',
|
||||
calendarChannelEventAssociations: '20202020-bdf8-4572-a2cc-ecbb6bcc3a02',
|
||||
eventAttendees: '20202020-e07e-4ccb-88f5-6f3d00458eec',
|
||||
eventParticipants: '20202020-e07e-4ccb-88f5-6f3d00458eec',
|
||||
};
|
||||
|
||||
export const commentStandardFieldIds = {
|
||||
@ -232,7 +232,7 @@ export const personStandardFieldIds = {
|
||||
favorites: '20202020-4073-4117-9cf1-203bcdc91cbd',
|
||||
attachments: '20202020-cd97-451f-87fa-bcb789bdbf3a',
|
||||
messageParticipants: '20202020-498e-4c61-8158-fa04f0638334',
|
||||
calendarEventAttendees: '20202020-52ee-45e9-a702-b64b3753e3a9',
|
||||
calendarEventParticipants: '20202020-52ee-45e9-a702-b64b3753e3a9',
|
||||
events: '20202020-a43e-4873-9c23-e522de906ce5',
|
||||
};
|
||||
|
||||
@ -293,7 +293,7 @@ export const workspaceMemberStandardFieldIds = {
|
||||
connectedAccounts: '20202020-e322-4bde-a525-727079b4a100',
|
||||
messageParticipants: '20202020-8f99-48bc-a5eb-edd33dd54188',
|
||||
blocklist: '20202020-6cb2-4161-9f29-a4b7f1283859',
|
||||
calendarEventAttendees: '20202020-0dbc-4841-9ce1-3e793b5b3512',
|
||||
calendarEventParticipants: '20202020-0dbc-4841-9ce1-3e793b5b3512',
|
||||
events: '20202020-e15b-47b8-94fe-8200e3c66615',
|
||||
};
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ export const standardObjectIds = {
|
||||
blocklist: '20202020-0408-4f38-b8a8-4d5e3e26e24d',
|
||||
calendarChannelEventAssociation: '20202020-491b-4aaa-9825-afd1bae6ae00',
|
||||
calendarChannel: '20202020-e8f2-40e1-a39c-c0e0039c5034',
|
||||
calendarEventAttendee: '20202020-a1c3-47a6-9732-27e5b1e8436d',
|
||||
calendarEventParticipant: '20202020-a1c3-47a6-9732-27e5b1e8436d',
|
||||
calendarEvent: '20202020-8f1d-4eef-9f85-0d1965e27221',
|
||||
comment: '20202020-435f-4de9-89b5-97e32233bf5f',
|
||||
company: '20202020-b374-4779-a561-80086cb2e17f',
|
||||
|
||||
@ -5,7 +5,7 @@ import { AttachmentObjectMetadata } from 'src/modules/attachment/standard-object
|
||||
import { BlocklistObjectMetadata } from 'src/modules/connected-account/standard-objects/blocklist.object-metadata';
|
||||
import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event.object-metadata';
|
||||
import { CalendarChannelObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
|
||||
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
|
||||
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
|
||||
import { CommentObjectMetadata } from 'src/modules/activity/standard-objects/comment.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/modules/company/standard-objects/company.object-metadata';
|
||||
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
|
||||
@ -53,5 +53,5 @@ export const standardObjectMetadataDefinitions = [
|
||||
CalendarEventObjectMetadata,
|
||||
CalendarChannelObjectMetadata,
|
||||
CalendarChannelEventAssociationObjectMetadata,
|
||||
CalendarEventAttendeeObjectMetadata,
|
||||
CalendarEventParticipantObjectMetadata,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user