Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions services/libs/common_services/src/services/member-organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,30 +201,27 @@ export function inferMemberOrganizationStintChanges(
continue
}

// 5. Only split when another org clearly sits between this stint and the new date.
// Overlapping orgs are treated as concurrent evidence, not a break in the stint.
// 5. Only split when another org has meaningful exclusive presence in the gap
// between the closest same-org stint and the new date (>30 days).
// Concurrent/overlapping orgs that barely extend into the gap are not career breaks.
const isForward = targetDate > neighbor.dateEnd
const gapStart = isForward ? neighbor.dateEnd : targetDate
const gapEnd = isForward ? targetDate : neighbor.dateStart

const hasSeparator = stints.some((s) => {
if (
s.organizationId === organizationId ||
!s.dateStart ||
!s.dateEnd ||
diff(s.dateStart, s.dateEnd) < 30
) {
if (s.organizationId === organizationId || !s.dateStart || !s.dateEnd) {
return false
}

if (isForward) {
return (
(s.dateStart > neighbor.dateEnd && s.dateStart <= targetDate) ||
Comment thread
skwowet marked this conversation as resolved.
(s.dateEnd > neighbor.dateEnd && s.dateEnd <= targetDate)
)
// Wide umbrella orgs that fully wrap the neighbor are concurrent, not career breaks
if (s.dateStart <= neighbor.dateStart && s.dateEnd >= neighbor.dateEnd) {
return false
}

return (
(s.dateStart >= targetDate && s.dateStart < neighbor.dateStart) ||
(s.dateEnd >= targetDate && s.dateEnd < neighbor.dateStart)
)
const overlapStart = s.dateStart > gapStart ? s.dateStart : gapStart
const overlapEnd = s.dateEnd < gapEnd ? s.dateEnd : gapEnd

return overlapStart < overlapEnd && diff(overlapStart, overlapEnd) > 30
})

if (hasSeparator) {
Expand Down
Loading