Fix-messaging-calendar-issues (#11424)
- fixing Event Calendar bug due to TypeORM limitations - avoid systematic crash on contact creation jobs, simply logging
This commit is contained in:
@ -106,13 +106,18 @@ export class CalendarEventsImportService {
|
|||||||
(event) => event.externalId,
|
(event) => event.externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const BATCH_SIZE = 1000;
|
||||||
|
|
||||||
|
for (let i = 0; i < filteredEvents.length; i = i + BATCH_SIZE) {
|
||||||
|
const eventsBatch = filteredEvents.slice(i, i + BATCH_SIZE);
|
||||||
|
|
||||||
await this.calendarSaveEventsService.saveCalendarEventsAndEnqueueContactCreationJob(
|
await this.calendarSaveEventsService.saveCalendarEventsAndEnqueueContactCreationJob(
|
||||||
filteredEvents,
|
eventsBatch,
|
||||||
calendarChannel,
|
calendarChannel,
|
||||||
connectedAccount,
|
connectedAccount,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
const calendarChannelEventAssociationRepository =
|
const calendarChannelEventAssociationRepository =
|
||||||
await this.twentyORMManager.getRepository<CalendarChannelEventAssociationWorkspaceEntity>(
|
await this.twentyORMManager.getRepository<CalendarChannelEventAssociationWorkspaceEntity>(
|
||||||
'calendarChannelEventAssociation',
|
'calendarChannelEventAssociation',
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import compact from 'lodash.compact';
|
|||||||
import { Any, EntityManager, Repository } from 'typeorm';
|
import { Any, EntityManager, Repository } from 'typeorm';
|
||||||
|
|
||||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||||
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { FieldActorSource } from 'src/engine/metadata-modules/field-metadata/composite-types/actor.composite-type';
|
import { FieldActorSource } from 'src/engine/metadata-modules/field-metadata/composite-types/actor.composite-type';
|
||||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||||
@ -36,6 +37,7 @@ export class CreateCompanyAndContactService {
|
|||||||
@InjectRepository(ObjectMetadataEntity, 'metadata')
|
@InjectRepository(ObjectMetadataEntity, 'metadata')
|
||||||
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
|
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
|
||||||
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
||||||
|
private readonly exceptionHandlerService: ExceptionHandlerService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private async createCompaniesAndPeople(
|
private async createCompaniesAndPeople(
|
||||||
@ -205,6 +207,7 @@ export class CreateCompanyAndContactService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const contactsBatch of contactsBatches) {
|
for (const contactsBatch of contactsBatches) {
|
||||||
|
try {
|
||||||
const createdPeople = await this.createCompaniesAndPeople(
|
const createdPeople = await this.createCompaniesAndPeople(
|
||||||
connectedAccount,
|
connectedAccount,
|
||||||
contactsBatch,
|
contactsBatch,
|
||||||
@ -225,6 +228,13 @@ export class CreateCompanyAndContactService {
|
|||||||
})),
|
})),
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
this.exceptionHandlerService.captureExceptions([error], {
|
||||||
|
workspace: {
|
||||||
|
id: workspaceId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user