Skip to content

Commit 416c0e1

Browse files
committed
Merge branch 'main' into github-sync-CM-514
2 parents fb8122b + 7f09a25 commit 416c0e1

14 files changed

Lines changed: 322 additions & 336 deletions

File tree

backend/src/services/memberService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,11 @@ export default class MemberService extends LoggerBase {
957957
} else if (key === 'contributions') {
958958
// check secondary member has any contributions to extract from current member
959959
if (member.contributions && Array.isArray(member.contributions)) {
960+
const secondaryContributions = Array.isArray(secondaryBackup.contributions)
961+
? secondaryBackup.contributions
962+
: []
960963
member.contributions = member.contributions.filter(
961-
(c) => !(secondaryBackup.contributions || []).some((s) => s.id === c.id),
964+
(c) => !secondaryContributions.some((s) => s.id === c.id),
962965
)
963966
}
964967
} else if (

services/apps/members_enrichment_worker/src/activities/enrichment.ts

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,19 @@ export async function updateMemberUsingSquashedPayload(
249249
return await svc.postgres.writer.transactionally(async (tx) => {
250250
let updated = false
251251
const qx = dbStoreQx(tx)
252-
const promises = []
253252

254253
// process identities
255254
if (squashedPayload.identities.length > 0) {
256255
svc.log.debug({ memberId }, 'Adding to member identities!')
257256
for (const i of squashedPayload.identities) {
258257
updated = true
259-
promises.push(
260-
upsertMemberIdentity(qx, {
261-
memberId,
262-
platform: i.platform,
263-
type: i.type,
264-
value: i.value,
265-
verified: i.verified,
266-
}),
267-
)
258+
await upsertMemberIdentity(qx, {
259+
memberId,
260+
platform: i.platform,
261+
type: i.type,
262+
value: i.value,
263+
verified: i.verified,
264+
})
268265
}
269266
}
270267

@@ -273,30 +270,22 @@ export async function updateMemberUsingSquashedPayload(
273270
// it's ommited from the payload because it takes a lot of space
274271
svc.log.debug('Processing contributions! ', { memberId, hasContributions })
275272
if (hasContributions) {
276-
promises.push(
277-
findMemberEnrichmentCache([MemberEnrichmentSource.PROGAI], memberId)
278-
.then((caches) => {
279-
if (caches.length > 0 && caches[0].data) {
280-
const progaiService = EnrichmentSourceServiceFactory.getEnrichmentSourceService(
281-
MemberEnrichmentSource.PROGAI,
282-
svc.log,
283-
)
284-
return progaiService.normalize(caches[0].data)
285-
}
286-
287-
return undefined
288-
})
289-
.then((normalized) => {
290-
if (normalized) {
291-
const typed = normalized as IMemberEnrichmentDataNormalized
273+
const caches = await findMemberEnrichmentCache([MemberEnrichmentSource.PROGAI], memberId)
274+
if (caches?.length > 0 && caches[0]?.data) {
275+
const progaiService = EnrichmentSourceServiceFactory.getEnrichmentSourceService(
276+
MemberEnrichmentSource.PROGAI,
277+
svc.log,
278+
)
279+
const normalized = progaiService.normalize(caches[0].data)
280+
if (normalized) {
281+
const typed = normalized as IMemberEnrichmentDataNormalized
292282

293-
if (typed.contributions) {
294-
updated = true
295-
return updateMemberContributions(qx, memberId, typed.contributions)
296-
}
297-
}
298-
}),
299-
)
283+
if (typed.contributions) {
284+
updated = true
285+
await updateMemberContributions(qx, memberId, typed.contributions)
286+
}
287+
}
288+
}
300289
}
301290

302291
// process attributes
@@ -312,7 +301,7 @@ export async function updateMemberUsingSquashedPayload(
312301
attributes = await setAttributesDefaultValues(attributes, priorities)
313302
}
314303
updated = true
315-
promises.push(updateMemberAttributes(qx, memberId, attributes))
304+
await updateMemberAttributes(qx, memberId, attributes)
316305
}
317306

318307
// process reach
@@ -332,7 +321,7 @@ export async function updateMemberUsingSquashedPayload(
332321
}
333322

334323
updated = true
335-
promises.push(updateMemberReach(qx, memberId, reach))
324+
await updateMemberReach(qx, memberId, reach)
336325
}
337326
}
338327

@@ -422,7 +411,7 @@ export async function updateMemberUsingSquashedPayload(
422411
if (results.toDelete.length > 0) {
423412
for (const org of results.toDelete) {
424413
updated = true
425-
promises.push(deleteMemberOrgById(tx.transaction(), memberId, org.id))
414+
await deleteMemberOrgById(tx.transaction(), memberId, org.id)
426415
}
427416
}
428417

@@ -432,30 +421,26 @@ export async function updateMemberUsingSquashedPayload(
432421
throw new Error('Organization ID is missing!')
433422
}
434423
updated = true
435-
promises.push(
436-
insertWorkExperience(
437-
tx.transaction(),
438-
memberId,
439-
org.organizationId,
440-
org.title,
441-
org.startDate,
442-
org.endDate,
443-
org.source,
444-
),
424+
await insertWorkExperience(
425+
tx.transaction(),
426+
memberId,
427+
org.organizationId,
428+
org.title,
429+
org.startDate,
430+
org.endDate,
431+
org.source,
445432
)
446433
}
447434
}
448435

449436
if (results.toUpdate.size > 0) {
450437
for (const [org, toUpdate] of results.toUpdate) {
451438
updated = true
452-
promises.push(updateMemberOrg(tx.transaction(), memberId, org, toUpdate))
439+
await updateMemberOrg(tx.transaction(), memberId, org, toUpdate)
453440
}
454441
}
455442
}
456443

457-
await Promise.all(promises)
458-
459444
if (updated) {
460445
await setMemberEnrichmentUpdatedAt(tx.transaction(), memberId)
461446
await syncMember(memberId)

services/apps/members_enrichment_worker/src/schedules/getMembersToEnrich.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const scheduleMembersEnrichment = async () => {
2424
type: 'startWorkflow',
2525
workflowType: getMembersToEnrich,
2626
taskQueue: 'members-enrichment',
27-
workflowExecutionTimeout: '20 minutes',
27+
workflowExecutionTimeout: '2 hours',
2828
retry: {
2929
initialInterval: '15 seconds',
3030
backoffCoefficient: 2,

services/apps/members_enrichment_worker/src/workflows/enrichMember.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const {
2424
hasRemainingCredits,
2525
getMemberById,
2626
} = proxyActivities<typeof activities>({
27-
startToCloseTimeout: '5 minutes',
27+
startToCloseTimeout: '10 minutes',
2828
retry: {
2929
initialInterval: '60s',
3030
backoffCoefficient: 2.0,
@@ -82,7 +82,7 @@ export async function enrichMember(
8282
workflowId: 'member-enrichment/' + input.id + '/processMemberSources',
8383
cancellationType: ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED,
8484
parentClosePolicy: ParentClosePolicy.PARENT_CLOSE_POLICY_REQUEST_CANCEL,
85-
workflowExecutionTimeout: '15 minutes',
85+
workflowExecutionTimeout: '25 minutes',
8686
retry: {
8787
backoffCoefficient: 2,
8888
maximumAttempts: 10,

services/apps/members_enrichment_worker/src/workflows/getMembersToEnrich.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { chunkArray } from '../utils/common'
1414
import { enrichMember } from './enrichMember'
1515

1616
const { getEnrichableMembers, getMaxConcurrentRequests } = proxyActivities<typeof activities>({
17-
startToCloseTimeout: '10 minutes',
17+
startToCloseTimeout: '15 minutes',
1818
})
1919

2020
export async function getMembersToEnrich(): Promise<void> {
@@ -46,7 +46,7 @@ export async function getMembersToEnrich(): Promise<void> {
4646
workflowId: 'member-enrichment/' + member.id,
4747
cancellationType: ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED,
4848
parentClosePolicy: ParentClosePolicy.PARENT_CLOSE_POLICY_REQUEST_CANCEL,
49-
workflowExecutionTimeout: '15 minutes',
49+
workflowExecutionTimeout: '30 minutes',
5050
retry: {
5151
backoffCoefficient: 2,
5252
maximumAttempts: 10,

services/apps/merge_suggestions_worker/src/activities/common.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@ import {
1111
ILLMConsumableMember,
1212
ILLMConsumableOrganization,
1313
ILLMSuggestionVerdict,
14-
PlatformType,
1514
} from '@crowd/types'
1615

1716
import { svc } from '../main'
1817
import { ILLMResult } from '../types'
1918

20-
export const EMAIL_AS_USERNAME_PLATFORMS = [
21-
PlatformType.GIT,
22-
PlatformType.JIRA,
23-
PlatformType.CONFLUENCE,
24-
PlatformType.GERRIT,
25-
]
26-
2719
export async function getAllTenants(): Promise<ITenant[]> {
2820
const tenantRepository = new TenantRepository(svc.postgres.writer.connection(), svc.log)
2921
const tenants = await tenantRepository.getAllTenants()

0 commit comments

Comments
 (0)