feat: add recalculate all affiliation (IN-1083)#4038
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
Adds a new script to detect members with stale activityRelations.organizationId values (relative to non-deleted memberOrganizations) and trigger memberUpdate Temporal workflows to recalculate affiliations.
Changes:
- Introduces
recalculate-all-affiliations.tsto page through members, detect stale org attributions, and triggermemberUpdateworkflows with concurrency controls. - Exposes the script via a new
pnpm run recalculate-all-affiliationspackage.json entry.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| services/apps/script_executor_worker/src/bin/recalculate-all-affiliations.ts | Implements paging + detection query + Temporal workflow triggering for affiliation recalculation. |
| services/apps/script_executor_worker/package.json | Adds a runnable script entry for the new recalculation tool. |
💡 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 1 out of 2 changed files in this pull request and generated no new comments.
💡 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 1 out of 2 changed files in this pull request and generated no new 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>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
521c6dd to
b9782ca
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 c0a7980. Configure here.
| memberOrganizationIds: activeOrgIds, | ||
| syncToOpensearch: true, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
Stale orgs excluded from OpenSearch sync after recalculation
Medium Severity
The memberOrganizationIds passed to the memberUpdate workflow only contains activeOrgIds, but staleOrgIds are also needed. After refreshMemberOrganizationAffiliations recalculates affiliations in the DB, activities previously attributed to stale orgs get re-attributed. The stale orgs' data in OpenSearch remains outdated because syncOrganization is never called for them. Both activeOrgIds and staleOrgIds need to be included so all affected organizations are synced.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c0a7980. Configure here.


Note
Medium Risk
Medium risk because it introduces a new bulk remediation script that runs wide DB scans and can enqueue large volumes of
memberUpdateTemporal workflows, potentially impacting load and data correctness if misused.Overview
Adds a new
recalculate-all-affiliationsscript (wired intoscript_executor_workerpackage.json) to find members whoseactivityRelations.organizationIdreferences aren’t present as activememberOrganizations.The script pages through member IDs, reports/limits results in
--dry-run, and in live mode triggersmemberUpdateworkflows (configurable concurrency/delays, resume cursor, max pages) to recompute affiliations and sync to OpenSearch.Reviewed by Cursor Bugbot for commit c0a7980. Bugbot is set up for automated code reviews on this repo. Configure here.