Skip to content

Commit 7ddce8b

Browse files
committed
Prevent organizations enrichments with 0 activities
1 parent 17b0279 commit 7ddce8b

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

backend/src/bin/scripts/enrich-members-and-organizations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ if (parameters.help || (!parameters.tenant && (!parameters.organization || !para
138138
service: 'enrich-organizations',
139139
tenantId,
140140
// Since there is no pagination implemented for the organizations enrichment,
141-
// we set a limit of 20,000 to ensure all organizations are included when enriched in bulk.
142-
maxEnrichLimit: 20000,
141+
// we set a limit of 10,000 to ensure all organizations are included when enriched in bulk.
142+
maxEnrichLimit: 10000,
143143
} as NodeWorkerMessageBase
144144

145145
await sendNodeWorkerMessage(tenantId, payload)

backend/src/database/repositories/organizationRepository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class OrganizationRepository {
5757
,org."crunchbase"
5858
,org."github"
5959
,org."description"
60+
,activity."orgActivityCount"
6061
FROM "organizations" as org
6162
JOIN "organizationCaches" cach ON org."name" = cach."name"
6263
JOIN orgActivities activity ON activity."organizationId" = org."id"

backend/src/services/premium/enrichment/organizationEnrichmentService.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,22 @@ export default class OrganizationEnrichmentService extends LoggerBase {
7676
this.maxOrganizationsLimit,
7777
this.options,
7878
)) {
79-
const data = await this.getEnrichment(instance)
80-
if (data) {
81-
const org = this.convertEnrichedDataToOrg(data, instance)
82-
enrichedOrganizations.push({ ...org, id: instance.id, tenantId: this.tenantId })
83-
enrichedCacheOrganizations.push({ ...org, id: instance.cachId })
84-
} else {
85-
const lastEnrichedAt = new Date()
86-
enrichedOrganizations.push({
87-
...instance,
88-
id: instance.id,
89-
tenantId: this.tenantId,
90-
lastEnrichedAt,
91-
})
92-
enrichedCacheOrganizations.push({ ...instance, id: instance.cachId, lastEnrichedAt })
79+
if (instance.activityCount > 0) {
80+
const data = await this.getEnrichment(instance)
81+
if (data) {
82+
const org = this.convertEnrichedDataToOrg(data, instance)
83+
enrichedOrganizations.push({ ...org, id: instance.id, tenantId: this.tenantId })
84+
enrichedCacheOrganizations.push({ ...org, id: instance.cachId })
85+
} else {
86+
const lastEnrichedAt = new Date()
87+
enrichedOrganizations.push({
88+
...instance,
89+
id: instance.id,
90+
tenantId: this.tenantId,
91+
lastEnrichedAt,
92+
})
93+
enrichedCacheOrganizations.push({ ...instance, id: instance.cachId, lastEnrichedAt })
94+
}
9395
}
9496
}
9597
const orgs = await this.update(enrichedOrganizations, enrichedCacheOrganizations)

backend/src/services/premium/enrichment/types/organizationEnrichmentTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface IOrganization {
1111
tenantId?: string
1212
website?: string
1313
location?: string
14+
activityCount?: number
1415
description?: IEnrichmentResponse['summary']
1516
employeeCountByCountry?: IEnrichmentResponse['employee_count_by_country']
1617
type?: IEnrichmentResponse['type']

0 commit comments

Comments
 (0)