Skip to content

Commit 891e680

Browse files
committed
chore: add more debugger logs
1 parent 76a4fed commit 891e680

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

services/apps/organizations_enrichment_worker/src/sources/internal-api/service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ export default class EnrichmentServiceInternalAPI
5252
): Promise<IOrganizationEnrichmentDataInternalAPI | null> {
5353
let response: IOrganizationEnrichmentDataInternalAPIResponse | undefined
5454

55+
console.log(
56+
'[DEBUG] Internal API URL:',
57+
process.env['CROWD_ORGANIZATION_ENRICHMENT_INTERNAL_API_URL'],
58+
)
59+
60+
console.log(
61+
'[DEBUG] Internal API Key:',
62+
process.env['CROWD_ORGANIZATION_ENRICHMENT_INTERNAL_API_KEY'],
63+
)
64+
65+
console.log('[DEBUG] Input:', {
66+
name: input.displayName,
67+
urls: input.domains.map((domain) => cleanURL(domain.value)),
68+
})
69+
5570
try {
5671
const url = `${process.env['CROWD_ORGANIZATION_ENRICHMENT_INTERNAL_API_URL']}`
5772
const config = {

services/apps/organizations_enrichment_worker/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ export interface IOrganizationEnrichmentDataNormalized {
4747

4848
export interface IGetOrganizationsToEnrichInput {
4949
testRun?: boolean
50+
perRunLimit?: number
5051
}

services/apps/organizations_enrichment_worker/src/workflows/enrichOrganization.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

services/apps/organizations_enrichment_worker/src/workflows/getOrganizationsToEnrich.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const { getEnrichableOrganizations, getMaxConcurrentRequests } = proxyActivities
2222
export async function getOrganizationsToEnrich(
2323
input: IGetOrganizationsToEnrichInput,
2424
): Promise<void> {
25-
const QUERY_FOR_ENRICHABLE_ORGANIZATIONS_PER_RUN = 5
25+
const QUERY_FOR_ENRICHABLE_ORGANIZATIONS_PER_RUN = input.perRunLimit ?? 1
2626
const source = OrganizationEnrichmentSource.INTERNAL_API
2727

2828
const organizations = await getEnrichableOrganizations(

0 commit comments

Comments
 (0)