fix: refresh affiliation on update (CM-1118)#4020
Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
|
|
There was a problem hiding this comment.
Pull request overview
This PR ensures member affiliations are recalculated when the members enrichment worker updates a member’s work experiences (memberOrganizations), addressing cases where affiliation state could otherwise remain stale after enrichment-driven updates.
Changes:
- Track organization IDs affected by work experience deletes/creates/updates during enrichment.
- Trigger
CommonMemberService.startAffiliationRecalculation(...)after the transaction completes to refresh affiliations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
services/apps/members_enrichment_worker/src/activities/enrichment.ts
Outdated
Show resolved
Hide resolved
services/apps/members_enrichment_worker/src/activities/enrichment.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 8497e07. Configure here.
services/apps/members_enrichment_worker/src/activities/enrichment.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
joanagmaia
left a comment
There was a problem hiding this comment.
@skwowet fyi this is a critical issue in production we noticed today. Tagging you for visibility
|
@joanagmaia Thanks for the heads-up and also, good catch! |

Note
Medium Risk
Adds a new post-update Temporal-driven affiliation recalculation step based on changed member organizations; incorrect org ID collection or job triggering could cause missed or excess recalculations and added load.
Overview
When enrichment updates a member, the worker now tracks which organization affiliations were affected by work-experience deletes/creates/updates.
After the DB transaction completes, it uses
CommonMemberService.startAffiliationRecalculationto recompute affiliations for the member and the deduped set of affected org IDs, while preserving the existingdidUpdate/updatedAtvslastTriedAtbehavior.Reviewed by Cursor Bugbot for commit 5368a19. Bugbot is set up for automated code reviews on this repo. Configure here.