fix: recalculate affiliations on update member orgs (IN-1083)#4039
fix: recalculate affiliations on update member orgs (IN-1083)#4039
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR ensures member affiliation data is recalculated after a member’s work experiences (member organizations) are updated, by tracking which organizations were affected and triggering the existing Temporal memberUpdate workflow.
Changes:
- Track organization IDs affected by member-organization deletes/creates/updates during
updateMemberOrganizations. - Trigger
startAffiliationRecalculationafter the update to recompute affiliations (and currently force OpenSearch sync).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
2a0b8d6 to
2294c0d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 b65c266. Configure here.
| await commonMemberService.startAffiliationRecalculation( | ||
| id, | ||
| (data.organizations || []).map((o) => o.id), | ||
| allAffectedOrgIds, |
There was a problem hiding this comment.
Unnecessary Temporal workflow on every member update
Medium Severity
In the update method, startAffiliationRecalculation is called unconditionally — even when data.organizations is falsy and no org changes occurred. When there are no orgs, both existingOrgIds and newOrgIds are empty, yet a Temporal memberUpdate workflow is still started (calling refreshMemberOrganizationAffiliations). The upsert method correctly guards this with if (data.organizations), but the update method lacks this guard. Every member field update (e.g. displayName) unnecessarily triggers an affiliation recalculation workflow.
Reviewed by Cursor Bugbot for commit b65c266. Configure here.


Note
Medium Risk
Changes workflow triggering and the set of organization IDs used for affiliation recomputation, which can affect correctness/performance of affiliation data if mis-scoped or called too often.
Overview
Ensures member affiliation data is recalculated whenever a member’s organizations are added/updated.
On backend member
upsert/update, the code now fetches existing organization IDs and triggersCommonMemberService.startAffiliationRecalculationwith the union of old + new org IDs so removals and additions are both covered. The data sink worker also triggers the recalculation workflow after it adds organizations to a member, andupdateMemberOrganizationsnow normalizes org inputs consistently;startAffiliationRecalculationadds structured logging before starting the Temporal workflow.Reviewed by Cursor Bugbot for commit b65c266. Bugbot is set up for automated code reviews on this repo. Configure here.