Skip to content

Commit

Permalink
Make search sync asynchronous when merging orgs (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
sausage-todd authored Jan 10, 2024
1 parent 76c5832 commit b965648
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions backend/src/services/organizationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -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,
Expand Down

0 comments on commit b965648

Please sign in to comment.