Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make search sync asynchronous when merging orgs #2053

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading