Skip to content

Commit 24c466c

Browse files
committed
refactor: improve employment processing logic in CommonMemberService
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent d22a0ba commit 24c466c

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

services/libs/common_services/src/services/common.member.service.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,26 @@ export class CommonMemberService extends LoggerBase {
209209
// 3. Date matching: work history active at this timestamp
210210
const currentEmployments = await findMemberWorkExperience(this.qx, memberId, timestamp)
211211
if (currentEmployments.length > 0) {
212-
const organizationIds = [...new Set(currentEmployments.map((row) => row.organizationId))]
213-
const memberOrgDomains = await fetchManyOrganizationVerifiedPrimaryDomains(
214-
this.qx,
215-
organizationIds,
216-
)
217-
218-
// Also applies when step 2 had a domain but no matching MO yet (e.g. ingest before stint inference).
219-
const employments = preferCompanyOverUniversityWhenOverlapping(
220-
currentEmployments,
221-
memberOrgDomains,
222-
)
223-
212+
let employments = currentEmployments
213+
214+
if (employments.length > 1) {
215+
const organizationIds = [
216+
...new Set(employments.map((row) => row.organizationId)),
217+
]
218+
219+
const memberOrgDomains = await fetchManyOrganizationVerifiedPrimaryDomains(
220+
this.qx,
221+
organizationIds,
222+
)
223+
224+
// Also applies when step 2 found a domain but no matching member organization yet
225+
// (e.g. ingest before stint inference).
226+
employments = preferCompanyOverUniversityWhenOverlapping(
227+
employments,
228+
memberOrgDomains,
229+
)
230+
}
231+
224232
return this.decidePrimaryOrganizationId(employments)
225233
}
226234

0 commit comments

Comments
 (0)