From b96564854e8ef5f9fda67b3289b59f414ca657dd Mon Sep 17 00:00:00 2001 From: Mish Savelyev <1564970+sausage-todd@users.noreply.github.com> Date: Wed, 10 Jan 2024 09:49:33 +0100 Subject: [PATCH] Make search sync asynchronous when merging orgs (#2053) --- backend/src/services/organizationService.ts | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/backend/src/services/organizationService.ts b/backend/src/services/organizationService.ts index 0216bb9e9d..ca7b2f65ca 100644 --- a/backend/src/services/organizationService.ts +++ b/backend/src/services/organizationService.ts @@ -160,6 +160,23 @@ export default class OrganizationService extends LoggerBase { this.options, ) + const searchSyncService = new SearchSyncService(this.options, SyncMode.ASYNCHRONOUS) + + await searchSyncService.triggerOrganizationSync(this.options.currentTenant.id, originalId) + await searchSyncService.triggerRemoveOrganization(this.options.currentTenant.id, toMergeId) + + // sync organization members + await searchSyncService.triggerOrganizationMembersSync( + this.options.currentTenant.id, + originalId, + ) + + // sync organization activities + await searchSyncService.triggerOrganizationActivitiesSync( + this.options.currentTenant.id, + originalId, + ) + await this.options.temporal.workflow.start('finishOrganizationMerging', { taskQueue: 'entity-merging', workflowId: `finishOrganizationMerging/${originalId}/${toMergeId}`, @@ -178,23 +195,6 @@ export default class OrganizationService extends LoggerBase { }, }) - const searchSyncService = new SearchSyncService(this.options) - - await searchSyncService.triggerOrganizationSync(this.options.currentTenant.id, originalId) - await searchSyncService.triggerRemoveOrganization(this.options.currentTenant.id, toMergeId) - - // sync organization members - await searchSyncService.triggerOrganizationMembersSync( - this.options.currentTenant.id, - originalId, - ) - - // sync organization activities - await searchSyncService.triggerOrganizationActivitiesSync( - this.options.currentTenant.id, - originalId, - ) - this.options.log.info({ originalId, toMergeId }, 'Organizations merged!') return { status: 200,