From 910e2f3353b3e77dc26da56b1b35eaccce9da2ca Mon Sep 17 00:00:00 2001 From: Umberto Sgueglia Date: Mon, 24 Aug 2026 14:09:00 +0200 Subject: [PATCH] fix: tombston in inferMemberOrganizationStintChanges Signed-off-by: Umberto Sgueglia --- .../src/services/member-organization.ts | 10 ++++++++++ .../data-access-layer/src/members/organizations.ts | 3 ++- services/libs/types/src/organizations.ts | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/libs/common_services/src/services/member-organization.ts b/services/libs/common_services/src/services/member-organization.ts index 5c2d9083f1..c5503b59ee 100644 --- a/services/libs/common_services/src/services/member-organization.ts +++ b/services/libs/common_services/src/services/member-organization.ts @@ -175,6 +175,12 @@ export function inferMemberOrganizationStintChanges( const activeRows = normalizedRows.filter((row) => !row.deletedAt) + const tombstonedOrgIds = new Set( + normalizedRows + .filter((row) => !!row.deletedAt && !!row.deletedBy) + .map((row) => row.organizationId), + ) + // Deleted dated rows suppress recreation for dates the user removed const deletedRows = normalizedRows.filter( (row): row is typeof row & { dateStart: string } => !!row.deletedAt && !!row.dateStart, @@ -199,6 +205,10 @@ export function inferMemberOrganizationStintChanges( })) for (const { organizationId, date: targetDate } of sortedDates) { + if (tombstonedOrgIds.has(organizationId)) { + continue + } + if ( deletedRows.some( (row) => diff --git a/services/libs/data-access-layer/src/members/organizations.ts b/services/libs/data-access-layer/src/members/organizations.ts index e8b1f46432..de6346fe57 100644 --- a/services/libs/data-access-layer/src/members/organizations.ts +++ b/services/libs/data-access-layer/src/members/organizations.ts @@ -83,7 +83,8 @@ export async function fetchMemberOrganizationsBySource( "title", "memberId", "source", - "deletedAt" + "deletedAt", + "deletedBy" FROM "memberOrganizations" WHERE "memberId" = $(memberId) AND "source" = $(source) diff --git a/services/libs/types/src/organizations.ts b/services/libs/types/src/organizations.ts index 78e74f4ed5..abd2dd5ead 100644 --- a/services/libs/types/src/organizations.ts +++ b/services/libs/types/src/organizations.ts @@ -63,6 +63,7 @@ export interface IMemberOrganization { verified?: boolean verifiedBy?: string deletedAt?: string + deletedBy?: string displayName?: string affiliationOverride?: IMemberOrganizationAffiliationOverride }