@@ -36,7 +36,7 @@ export async function enrichOrganization(
3636 const organization = await findOrganizationById ( input . id )
3737 if ( ! organization ) return
3838
39- console . log ( 'Enriching organization:' , input . id )
39+ console . log ( '[DEBUG] Enriching organization:' , input . id )
4040
4141 const [ cache ] = await findOrganizationEnrichmentCache ( [ source ] , input . id )
4242
@@ -46,14 +46,15 @@ export async function enrichOrganization(
4646 // Prepare enrichment input
4747 const enrichmentInput : IOrganizationEnrichmentSourceInput = await getEnrichmentInput ( input )
4848
49- console . log ( 'Enrichment input:' , enrichmentInput )
49+ console . log ( '[DEBUG] Enrichment input:' , enrichmentInput )
5050
5151 // Use LLM to pick the most relevant domain if multiple
5252 if ( enrichmentInput . domains . length > 1 ) {
5353 const mostRelevantDomain = await selectMostRelevantDomainWithLLM (
5454 input . id ,
5555 enrichmentInput . domains ,
5656 )
57+ console . log ( '[DEBUG] Most relevant domain selected by LLM:' , mostRelevantDomain )
5758 enrichmentInput . domains = [ mostRelevantDomain ]
5859 }
5960
@@ -62,7 +63,7 @@ export async function enrichOrganization(
6263 // Fetch new enrichment data
6364 const data = await getEnrichmentData ( source , enrichmentInput )
6465
65- console . log ( 'Enrichment data:' , JSON . stringify ( data , null , 2 ) )
66+ console . log ( '[DEBUG] Enrichment data:' , JSON . stringify ( data , null , 2 ) )
6667
6768 // Record enrichment attempt
6869 await touchOrganizationEnrichmentLastTriedAt ( input . id )
@@ -71,32 +72,32 @@ export async function enrichOrganization(
7172
7273 if ( ! cache ) {
7374 // First time enriching, create cache entry
74- console . log ( 'Creating cache entry for organization!' )
75+ console . log ( '[DEBUG] Creating cache entry for organization!' )
7576 await createOrganizationEnrichmentCache ( source , input . id , data )
7677 if ( data ) {
7778 changeInEnrichmentSourceData = true
7879 }
7980 } else if ( cache && ! data ) {
8081 // No new data, keep the old cache and update the timestamp
81- console . log ( 'No new data, keeping old cache and updating timestamp!' )
82+ console . log ( '[DEBUG] No new data, keeping old cache and updating timestamp!' )
8283 await touchOrganizationEnrichmentCacheUpdatedAt ( source , input . id )
8384 } else if ( cache && data ) {
8485 // Data changed, update cache
8586 if ( sourceHasDifferentDataComparedToCache ( cache , data ) ) {
86- console . log ( 'Data changed, updating cache!' )
87+ console . log ( '[DEBUG] Data changed, updating cache!' )
8788 await updateOrganizationEnrichmentCache ( source , input . id , data )
8889 changeInEnrichmentSourceData = true
8990 } else {
9091 // Data unchanged, keep the old cache and update the timestamp
91- console . log ( 'Data unchanged, keeping old cache and updating timestamp!' )
92+ console . log ( '[DEBUG] Data unchanged, keeping old cache and updating timestamp!' )
9293 await touchOrganizationEnrichmentCacheUpdatedAt ( source , input . id )
9394 }
9495 }
9596
9697 // Apply enrichment only if there’s new data to apply
9798 if ( changeInEnrichmentSourceData && data ) {
9899 const normalized = await normalizeEnrichmentData ( source , data )
99- console . log ( 'Normalized data:' , JSON . stringify ( normalized , null , 2 ) )
100+ console . log ( '[DEBUG] Normalized data:' , JSON . stringify ( normalized , null , 2 ) )
100101 await applyEnrichmentToOrganization ( input . id , normalized )
101102 }
102103}
0 commit comments