Skip to content

fix: soft-delete undated duplicate member organization rows#4070

Merged
skwowet merged 3 commits into
mainfrom
fix/cleanup-undated-member-org-rows
May 4, 2026
Merged

fix: soft-delete undated duplicate member organization rows#4070
skwowet merged 3 commits into
mainfrom
fix/cleanup-undated-member-org-rows

Conversation

@skwowet
Copy link
Copy Markdown
Collaborator

@skwowet skwowet commented May 4, 2026

Summary

This PR prevents duplicate "Unknown" work-history rows after email-domain stint inference.

When the cron job infers a dated email-domain row for a (memberId, organizationId), it now also soft-deletes any active undated rows for the same pair (dateStart IS NULL and dateEnd IS NULL).


Note

Medium Risk
Touches work-history persistence by soft-deleting rows (and related affiliation overrides), so a bug could remove legitimate undated records for affected orgs; scope is limited to inferred members/orgs with null dates.

Overview
Prevents duplicate "unknown date" work-history rows after email-domain stint inference by cleaning up any active memberOrganizations for the same member/org where both dateStart and dateEnd are NULL.

Adds deleteUndatedMemberOrganizations in the data-access layer to transactional soft-delete those undated rows and remove their memberOrganizationAffiliationOverrides, and invokes it at the end of inferMemberOrganizationStintChanges processing for the orgs affected in the current batch.

Reviewed by Cursor Bugbot for commit 5b0d264. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet skwowet self-assigned this May 4, 2026
Copilot AI review requested due to automatic review settings May 4, 2026 13:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

3 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

joanagmaia
joanagmaia previously approved these changes May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to clean up email-domain work-history data by soft-deleting undated member-organization rows once the stint inference job has produced dated rows for the same member/organization pair. It fits into the member affiliation pipeline in data-access-layer and the cron job that materializes inferred email-domain stints.

Changes:

  • Added a new DAL helper to soft-delete undated memberOrganizations rows for a member across a set of organizations.
  • Updated the stint inference cron job to call that cleanup after applying inferred insert/update changes.
  • Kept the cleanup scoped to member/org pairs derived from the inferred change set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
services/libs/data-access-layer/src/members/organizations.ts Adds the new soft-delete helper for undated member-organization rows.
services/apps/cron_service/src/jobs/inferMemberOrganizationStintChanges.job.ts Invokes the new cleanup helper after applying inferred stint changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/data-access-layer/src/members/organizations.ts Outdated
Comment thread services/libs/data-access-layer/src/members/organizations.ts Outdated
Comment thread services/libs/data-access-layer/src/members/organizations.ts Outdated
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5b0d264. Configure here.

Comment thread services/libs/data-access-layer/src/members/organizations.ts
@skwowet skwowet merged commit 18ae414 into main May 4, 2026
15 checks passed
@skwowet skwowet deleted the fix/cleanup-undated-member-org-rows branch May 4, 2026 16:03
Muawiya-contact pushed a commit to Muawiya-contact/crowd.dev that referenced this pull request May 11, 2026
…ndation#4070)

Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants