Skip to content

Commit 861b33f

Browse files
committed
fix: resolve pr reviews and comments
1 parent 3bd97f3 commit 861b33f

14 files changed

Lines changed: 21 additions & 22 deletions

File tree

backend/src/database/migrations/R__organizationEnrichmentMaterializedViews.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ drop materialized view if exists "organizationsGlobalActivityCount" cascade;
55
create materialized view "organizationsGlobalActivityCount" as
66
select
77
osa."organizationId",
8-
sum(osa."activityCount") as total_count
8+
sum(osa."activityCount") as total_count_estimate
99
from "organizationSegmentsAgg" osa
1010
where osa."segmentId" in (
1111
select id
@@ -19,4 +19,4 @@ order by sum(osa."activityCount") desc;
1919
create unique index ix_organization_global_activity_count_organization_id
2020
on "organizationsGlobalActivityCount" ("organizationId");
2121

22-
create index ix_organization_global_activity_count on "organizationsGlobalActivityCount" (total_count);
22+
create index ix_organization_global_activity_count_estimate on "organizationsGlobalActivityCount" (total_count_estimate);

services/apps/members_enrichment_worker/src/workflows/enrichMember.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const {
1818
findMemberEnrichmentCache,
1919
insertMemberEnrichmentCache,
2020
touchMemberEnrichmentCacheUpdatedAt,
21-
touchMemberEnrichmentLastTriedAt,
2221
updateMemberEnrichmentCache,
2322
isCacheObsolete,
2423
getEnrichmentInput,
@@ -62,9 +61,6 @@ export async function enrichMember(
6261

6362
const data = await getEnrichmentData(source, enrichmentInput)
6463

65-
// Record enrichment attempt
66-
await touchMemberEnrichmentLastTriedAt(input.id)
67-
6864
if (!cache) {
6965
await insertMemberEnrichmentCache(source, input.id, data)
7066
if (data) {

services/apps/members_enrichment_worker/src/workflows/processMemberSources.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
squashWorkExperiencesWithLLM,
1515
updateMemberUsingSquashedPayload,
1616
cleanAttributeValue,
17+
touchMemberEnrichmentLastTriedAt,
1718
} = proxyActivities<typeof activities>({
1819
startToCloseTimeout: '2 minutes',
1920
retry: {
@@ -309,5 +310,7 @@ export async function processMemberSources(args: IProcessMemberSourcesArgs): Pro
309310
return memberUpdated
310311
}
311312

313+
await touchMemberEnrichmentLastTriedAt(args.memberId)
314+
312315
return false
313316
}

services/apps/organizations_enrichment_worker/src/activities/enrichment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function applyEnrichmentToOrganization(
206206
const prepared = prepareOrganizationData(
207207
// organization attributes are expected to be flattened
208208
{ identities: data.identities, displayName: data.displayName, ...data.attributes },
209-
OrganizationAttributeSource.ENRICHMENT_INTERNAL_API,
209+
OrganizationAttributeSource.ENRICHMENT_LFX_INTERNAL_API,
210210
orgData,
211211
existingAttributes,
212212
)

services/apps/organizations_enrichment_worker/src/factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Logger } from '@crowd/logging'
33
import { OrganizationEnrichmentSource } from '@crowd/types'
44

5-
import EnrichmentServiceInternalAPI from './sources/internal-api/service'
5+
import EnrichmentServiceLFXInternalAPI from './sources/lfx-internal-api/service'
66
import { IOrganizationEnrichmentService } from './types'
77

88
export class OrganizationEnrichmentSourceServiceFactory {
@@ -11,8 +11,8 @@ export class OrganizationEnrichmentSourceServiceFactory {
1111
log: Logger,
1212
): IOrganizationEnrichmentService {
1313
switch (source) {
14-
case OrganizationEnrichmentSource.INTERNAL_API:
15-
return new EnrichmentServiceInternalAPI(log)
14+
case OrganizationEnrichmentSource.LFX_INTERNAL_API:
15+
return new EnrichmentServiceLFXInternalAPI(log)
1616
default:
1717
throw new Error(`Organization enrichment service for ${source} is not found!`)
1818
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export default class EnrichmentServiceInternalAPI
2525
extends LoggerBase
2626
implements IOrganizationEnrichmentService
2727
{
28-
public source: OrganizationEnrichmentSource = OrganizationEnrichmentSource.INTERNAL_API
28+
public source: OrganizationEnrichmentSource = OrganizationEnrichmentSource.LFX_INTERNAL_API
2929
public platform = `enrichment-${this.source}`
3030
public enrichOrganizationsWithActivityMoreThan = 10
3131

32-
public enrichableBySql = `"organizationsGlobalActivityCount".total_count > ${this.enrichOrganizationsWithActivityMoreThan}`
32+
public enrichableBySql = `"organizationsGlobalActivityCount".total_count_estimate > ${this.enrichOrganizationsWithActivityMoreThan}`
3333

3434
public maxConcurrentRequests = 5
3535

services/apps/organizations_enrichment_worker/src/sources/internal-api/types.ts renamed to services/apps/organizations_enrichment_worker/src/sources/lfx-internal-api/types.ts

File renamed without changes.

services/apps/organizations_enrichment_worker/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IOrganizationIdentity, OrganizationEnrichmentSource } from '@crowd/types'
22

3-
import { IOrganizationEnrichmentDataInternalAPI } from './sources/internal-api/types'
3+
import { IOrganizationEnrichmentDataInternalAPI } from './sources/lfx-internal-api/types'
44

55
export interface IOrganizationEnrichmentSourceInput {
66
organizationId: string

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ export async function enrichOrganization(
5959
// Fetch new enrichment data
6060
const data = await getEnrichmentData(source, enrichmentInput)
6161

62-
// Record enrichment attempt
63-
await touchOrganizationEnrichmentLastTriedAt(input.id)
64-
6562
let changeInEnrichmentSourceData = false
6663

6764
if (!cache) {
@@ -84,9 +81,12 @@ export async function enrichOrganization(
8481
}
8582
}
8683

87-
// Apply enrichment only if theres new data to apply
84+
// Apply enrichment only if there's new data to apply
8885
if (changeInEnrichmentSourceData && data) {
8986
const normalized = await normalizeEnrichmentData(source, data)
9087
await applyEnrichmentToOrganization(input.id, normalized)
9188
}
89+
90+
// Record enrichment processing attempt
91+
await touchOrganizationEnrichmentLastTriedAt(input.id)
9292
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function triggerOrganizationsEnrichment(
2323
input: ITriggerOrganizationsEnrichmentInput,
2424
): Promise<void> {
2525
const QUERY_FOR_ENRICHABLE_ORGANIZATIONS_PER_RUN = input.perRunLimit ?? 500
26-
const source = OrganizationEnrichmentSource.INTERNAL_API
26+
const source = OrganizationEnrichmentSource.LFX_INTERNAL_API
2727

2828
const organizations = await getEnrichableOrganizations(
2929
QUERY_FOR_ENRICHABLE_ORGANIZATIONS_PER_RUN,

0 commit comments

Comments
 (0)