File tree Expand file tree Collapse file tree
services/apps/members_enrichment_worker/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,10 +91,25 @@ export default class EnrichmentServiceCrustdata extends LoggerBase implements IE
9191 }
9292
9393 async isEnrichableBySource ( input : IEnrichmentSourceInput ) : Promise < boolean > {
94- const caches = await findMemberEnrichmentCacheForAllSources ( input . memberId )
94+ // Include cache rows with null data so we can detect members where
95+ // Crustdata was already attempted but returned no results.
96+ const caches = await findMemberEnrichmentCacheForAllSources ( input . memberId , true )
97+
98+ // Skip if Crustdata has already been tried for this member.
99+ const hasCrustdataCache = caches . some ( ( cache ) => cache . source === this . source )
100+ if ( hasCrustdataCache ) {
101+ this . log . debug (
102+ { memberId : input . memberId } ,
103+ 'Skipping Crustdata for previously enriched profile!' ,
104+ )
105+
106+ return false
107+ }
95108
109+ // Check other sources' caches for a LinkedIn identity to scrape.
110+ const cachesWithData = caches . filter ( ( cache ) => cache . data !== null )
96111 let hasEnrichableLinkedinInCache = false
97- for ( const cache of caches ) {
112+ for ( const cache of cachesWithData ) {
98113 if ( this . alsoFindInputsInSourceCaches . includes ( cache . source ) ) {
99114 const service = EnrichmentSourceServiceFactory . getEnrichmentSourceService (
100115 cache . source ,
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ export async function enrichMember(
7070 if ( data ) {
7171 changeInEnrichmentSourceData = true
7272 }
73+ } else if ( data === null && cache . data !== null ) {
74+ // Prevents overwriting valid data when a source intentionally skips a member (e.g., Crustdata).
75+ await touchMemberEnrichmentCacheUpdatedAt ( source , input . id )
7376 } else if ( sourceHasDifferentDataComparedToCache ( cache , data ) ) {
7477 await updateMemberEnrichmentCache ( source , input . id , data )
7578 changeInEnrichmentSourceData = true
You can’t perform that action at this time.
0 commit comments