diff --git a/services/libs/opensearch/src/service/member.sync.service.ts b/services/libs/opensearch/src/service/member.sync.service.ts index ca0f7c3142..2b9169c4bf 100644 --- a/services/libs/opensearch/src/service/member.sync.service.ts +++ b/services/libs/opensearch/src/service/member.sync.service.ts @@ -17,7 +17,7 @@ import { OrganizationField, findOrgById } from '@crowd/data-access-layer/src/org import { QueryExecutor, repoQx } from '@crowd/data-access-layer/src/queryExecutor' import { fetchManySegments } from '@crowd/data-access-layer/src/segments' import { DbStore } from '@crowd/database' -import { Logger, getChildLogger, logExecutionTimeV2 } from '@crowd/logging' +import { Logger, getChildLogger } from '@crowd/logging' import { RedisClient } from '@crowd/redis' import { IMemberAttribute, @@ -323,6 +323,10 @@ export class MemberSyncService { lastId, ) + if (memberIdData.length === 0) { + return [] + } + const membersWithActivities = await filterMembersWithActivities( this.qdbStore.connection(), memberIdData.map((m) => m.memberId), @@ -370,11 +374,7 @@ export class MemberSyncService { let memberData: IMemberSegmentAggregates[] try { - memberData = await logExecutionTimeV2( - async () => getMemberAggregates(this.qdbStore.connection(), memberId), - this.log, - 'getMemberAggregates', - ) + memberData = await getMemberAggregates(this.qdbStore.connection(), memberId) if (memberData.length === 0) { return @@ -420,19 +420,14 @@ export class MemberSyncService { if (memberData.length > 0) { try { - await logExecutionTimeV2( - async () => - this.memberRepo.transactionally( - async (txRepo) => { - const qx = repoQx(txRepo) - await cleanupMemberAggregates(qx, memberId) - await insertMemberSegments(qx, memberData) - }, - undefined, - true, - ), - this.log, - 'insertMemberSegments', + await this.memberRepo.transactionally( + async (txRepo) => { + const qx = repoQx(txRepo) + await cleanupMemberAggregates(qx, memberId) + await insertMemberSegments(qx, memberData) + }, + undefined, + true, ) documentsIndexed += memberData.length @@ -477,11 +472,7 @@ export class MemberSyncService { const prefixed = MemberSyncService.prefixData(data, attributes) await this.openSearchService.index(memberId, OpenSearchIndex.MEMBERS, prefixed) } - await logExecutionTimeV2( - async () => syncMembersToOpensearchForMergeSuggestions(memberId), - this.log, - 'syncMembersToOpensearchForMergeSuggestions', - ) + await syncMembersToOpensearchForMergeSuggestions(memberId) return syncResults } diff --git a/services/libs/opensearch/src/service/organization.sync.service.ts b/services/libs/opensearch/src/service/organization.sync.service.ts index 554f786390..402621db13 100644 --- a/services/libs/opensearch/src/service/organization.sync.service.ts +++ b/services/libs/opensearch/src/service/organization.sync.service.ts @@ -13,7 +13,7 @@ import { OrganizationField, findOrgById } from '@crowd/data-access-layer/src/org import { QueryExecutor, repoQx } from '@crowd/data-access-layer/src/queryExecutor' import { fetchManySegments } from '@crowd/data-access-layer/src/segments' import { DbStore } from '@crowd/database' -import { Logger, getChildLogger, logExecutionTime, logExecutionTimeV2 } from '@crowd/logging' +import { Logger, getChildLogger, logExecutionTime } from '@crowd/logging' import { IOrganizationBaseForMergeSuggestions, IOrganizationFullAggregatesOpensearch, @@ -317,11 +317,7 @@ export class OrganizationSyncService { for (const organizationId of organizationIds) { let orgData: IDbOrganizationAggregateData[] = [] try { - orgData = await logExecutionTimeV2( - async () => getOrgAggregates(this.qdbStore.connection(), organizationId), - this.log, - 'getOrgAggregates', - ) + orgData = await getOrgAggregates(this.qdbStore.connection(), organizationId) if (orgData.length > 0) { // get segment data to aggregate for projects and project groups @@ -370,19 +366,14 @@ export class OrganizationSyncService { if (orgData.length > 0) { try { - await logExecutionTimeV2( - async () => - this.writeOrgRepo.transactionally( - async (txRepo) => { - const qx = repoQx(txRepo) - await cleanupForOganization(qx, organizationId) - await insertOrganizationSegments(qx, orgData) - }, - undefined, - true, - ), - this.log, - 'insertOrganizationSegments', + await this.writeOrgRepo.transactionally( + async (txRepo) => { + const qx = repoQx(txRepo) + await cleanupForOganization(qx, organizationId) + await insertOrganizationSegments(qx, orgData) + }, + undefined, + true, ) organizationIdsToIndex.push(organizationId) @@ -432,11 +423,7 @@ export class OrganizationSyncService { organizationsSynced: organizationIds.length, } } - await logExecutionTimeV2( - async () => syncOrgsToOpensearchForMergeSuggestions(syncResults.organizationIdsToIndex), - this.log, - 'syncOrgsToOpensearchForMergeSuggestions', - ) + await syncOrgsToOpensearchForMergeSuggestions(syncResults.organizationIdsToIndex) return syncResults }