@@ -290,15 +290,15 @@ export async function updateMemberUsingSquashedPayload(
290290) : Promise < boolean > {
291291 const affectedOrgIds : string [ ] = [ ]
292292
293- const updated = await svc . postgres . writer . transactionally ( async ( tx ) => {
294- let updated = false
293+ const wasUpdated = await svc . postgres . writer . transactionally ( async ( tx ) => {
294+ let didUpdate = false
295295 const qx = dbStoreQx ( tx )
296296
297297 // process identities
298298 if ( squashedPayload . identities . length > 0 ) {
299299 svc . log . debug ( { memberId } , 'Adding to member identities!' )
300300 for ( const i of squashedPayload . identities ) {
301- updated = true
301+ didUpdate = true
302302 await createMemberIdentity (
303303 qx ,
304304 {
@@ -330,7 +330,7 @@ export async function updateMemberUsingSquashedPayload(
330330 const typed = normalized as IMemberEnrichmentDataNormalized
331331
332332 if ( typed . contributions ) {
333- updated = true
333+ didUpdate = true
334334 await updateMemberContributions ( qx , memberId , typed . contributions )
335335 }
336336 }
@@ -349,7 +349,7 @@ export async function updateMemberUsingSquashedPayload(
349349 const priorities = await getPriorityArray ( )
350350 attributes = await setAttributesDefaultValues ( attributes , priorities )
351351 }
352- updated = true
352+ didUpdate = true
353353 await updateMemberAttributes ( qx , memberId , attributes )
354354 }
355355
@@ -369,7 +369,7 @@ export async function updateMemberUsingSquashedPayload(
369369 total,
370370 }
371371
372- updated = true
372+ didUpdate = true
373373 await updateMemberReach ( qx , memberId , reach )
374374 }
375375 }
@@ -462,7 +462,7 @@ export async function updateMemberUsingSquashedPayload(
462462
463463 if ( results . toDelete . length > 0 ) {
464464 for ( const org of results . toDelete ) {
465- updated = true
465+ didUpdate = true
466466 affectedOrgIds . push ( org . orgId )
467467 await deleteMemberOrgById ( tx . transaction ( ) , org . id )
468468 }
@@ -473,7 +473,7 @@ export async function updateMemberUsingSquashedPayload(
473473 if ( ! org . organizationId ) {
474474 throw new Error ( 'Organization ID is missing!' )
475475 }
476- updated = true
476+ didUpdate = true
477477 affectedOrgIds . push ( org . organizationId )
478478
479479 const newMemberOrgId = await insertWorkExperience (
@@ -497,7 +497,7 @@ export async function updateMemberUsingSquashedPayload(
497497
498498 if ( results . toUpdate . size > 0 ) {
499499 for ( const [ memberOrg , toUpdate ] of results . toUpdate ) {
500- updated = true
500+ didUpdate = true
501501 affectedOrgIds . push ( memberOrg . orgId )
502502 const updatedMemberOrgId = await updateMemberOrg (
503503 tx . transaction ( ) ,
@@ -533,7 +533,7 @@ export async function updateMemberUsingSquashedPayload(
533533 }
534534 }
535535
536- if ( updated ) {
536+ if ( didUpdate ) {
537537 await setMemberEnrichmentUpdatedAt ( tx . transaction ( ) , memberId )
538538 await syncMember ( memberId )
539539 } else {
@@ -542,7 +542,7 @@ export async function updateMemberUsingSquashedPayload(
542542
543543 svc . log . debug ( { memberId } , 'Member sources processed successfully!' )
544544
545- return updated
545+ return didUpdate
546546 } )
547547
548548 if ( affectedOrgIds . length > 0 ) {
@@ -551,9 +551,7 @@ export async function updateMemberUsingSquashedPayload(
551551 svc . temporal ,
552552 svc . log ,
553553 )
554- await commonMemberService . startAffiliationRecalculation ( memberId , [
555- ...new Set ( affectedOrgIds ) ,
556- ] )
554+ await commonMemberService . startAffiliationRecalculation ( memberId , [ ...new Set ( affectedOrgIds ) ] , true )
557555 }
558556
559557 return updated
0 commit comments