Improve messaging/calendar create contact performance (#5314)

In this PR, I'm refactoring the way we associate messageParticipant post
person/company creation. Instead of looking a all person without
participant, we are passing the one that were just created.

Also, I'm making sure the message and messageParticipant creation
transaction is commited before creating person/company creation (and
then messageParticipant association)
This commit is contained in:
Charles Bochet
2024-05-06 23:43:18 +02:00
committed by GitHub
parent 5f467ab5ca
commit a2017eaeb7
11 changed files with 154 additions and 336 deletions

View File

@ -212,7 +212,7 @@ export class CalendarEventParticipantRepository {
handle: 'text',
displayName: 'text',
isOrganizer: 'boolean',
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responsestatus_enum"`,
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responseStatus_enum"`,
},
);

View File

@ -11,6 +11,7 @@ import { CalendarEventParticipant } from 'src/modules/calendar/types/calendar-ev
import { CalendarEventParticipantRepository } from 'src/modules/calendar/repositories/calendar-event-participant.repository';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { AddPersonIdAndWorkspaceMemberIdService } from 'src/modules/calendar-messaging-participant/services/add-person-id-and-workspace-member-id/add-person-id-and-workspace-member-id.service';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
@Injectable()
export class CalendarEventParticipantService {
@ -24,11 +25,13 @@ export class CalendarEventParticipantService {
) {}
public async updateCalendarEventParticipantsAfterPeopleCreation(
createdPeople: ObjectRecord<PersonObjectMetadata>[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<void> {
const participants =
await this.calendarEventParticipantRepository.getWithoutPersonIdAndWorkspaceMemberId(
await this.calendarEventParticipantRepository.getByHandles(
createdPeople.map((person) => person.email),
workspaceId,
);
@ -102,7 +105,7 @@ export class CalendarEventParticipantService {
handle: 'text',
displayName: 'text',
isOrganizer: 'boolean',
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responsestatus_enum"`,
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responseStatus_enum"`,
personId: 'uuid',
workspaceMemberId: 'uuid',
},