File tree Expand file tree Collapse file tree
services/apps/members_enrichment_worker/src/activities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -613,15 +613,24 @@ function prepareWorkExperiences(
613613 isHighConfidenceSourceSelectedForWorkExperiences : boolean ,
614614) : IWorkExperienceChanges {
615615 // we delete all the work experiences that were not manually created
616- let toDelete = oldVersion . filter ( ( c ) => c . source !== OrganizationSource . UI )
616+ const toDelete = oldVersion . filter ( ( c ) => c . source !== OrganizationSource . UI )
617617
618618 const toCreate : IMemberEnrichmentDataNormalizedOrganization [ ] = [ ]
619619 // eslint-disable-next-line @typescript-eslint/no-explicit-any
620620 const toUpdate : Map < IMemberOrganizationData , Record < string , any > > = new Map ( )
621621
622622 if ( isHighConfidenceSourceSelectedForWorkExperiences ) {
623- toDelete = oldVersion
624- toCreate . push ( ...newVersion )
623+ const uiEntries = oldVersion . filter ( ( c ) => c . source === OrganizationSource . UI )
624+ const filteredNewVersion = newVersion . filter (
625+ ( e ) =>
626+ ! uiEntries . some (
627+ ( ui ) =>
628+ e . title === ui . jobTitle &&
629+ e . identities &&
630+ e . identities . some ( ( i ) => i . organizationId === ui . orgId ) ,
631+ ) ,
632+ )
633+ toCreate . push ( ...filteredNewVersion )
625634 return {
626635 toDelete,
627636 toCreate,
You can’t perform that action at this time.
0 commit comments