Skip to content

fix: refresh affiliations after email-domain stint changes (CM-1216)#4181

Merged
skwowet merged 5 commits into
mainfrom
bugfix/CM-1216
Jun 10, 2026
Merged

fix: refresh affiliations after email-domain stint changes (CM-1216)#4181
skwowet merged 5 commits into
mainfrom
bugfix/CM-1216

Conversation

@skwowet

@skwowet skwowet commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

When activities are ingested, data-sink-worker affiliates them using the work history available at that moment and buffers verified email-domain dates for stint inference. The stint job later writes email-domain member organization rows, but it previously stopped there.

That left a timing gap: enrichment or a UI edit could trigger an affiliation refresh before the email-domain row existed, so activities would be refreshed against an incomplete timeline. When stint inference later created or updated the email-domain row, affiliations were not refreshed again, leaving downstream data stale even though the work history was now correct.

This change signals the per-member update workflow after stint inference persists real email-domain member organization changes. The refresh then runs after the email-domain row exists.

We also looked at whether stint should push members into a separate delayed Redis buffer and drain that later to coalesce multiple refresh signals, for example during onboarding when a member might get several email-domain updates over time. That felt like overkill for now. Within a single stint run, all buffered dates for a member are processed together and produce one signal. When the same member is picked up again later, it is usually because new dates arrived after the previous pass, which is a real work-history change worth refreshing. A day-long delay buffer would add another queue and keep affiliations stale longer for downstream systems, without solving a problem we are actually seeing in production.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet skwowet self-assigned this Jun 8, 2026
Copilot AI review requested due to automatic review settings June 8, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 closes a timing gap between email-domain stint inference (which persists email-domain member-organization rows) and downstream affiliation refreshes by signaling the per-member Temporal memberUpdate workflow after stint changes are actually applied, ensuring affiliations get recalculated once the new/updated rows exist.

Changes:

  • Import and initialize a Temporal client in the stint inference cron job.
  • After persisting inferred stint changes, signal the memberUpdate workflow for the affected member to refresh affiliations.

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

skwowet added 2 commits June 9, 2026 00:18
…nt inference

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 10, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread services/apps/cron_service/src/jobs/inferMemberOrganizationStintChanges.job.ts Outdated
themarolt
themarolt previously approved these changes Jun 10, 2026
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 10, 2026 11:41
@skwowet
skwowet merged commit 6d1be2b into main Jun 10, 2026
11 checks passed
@skwowet
skwowet deleted the bugfix/CM-1216 branch June 10, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines 69 to 78
if (changes.length > 0) {
ctx.log.debug({ memberId, changes }, 'Stint changes identified.')
await qx.tx((tx) => applyStintChanges(tx, changes))

ctx.log.debug(
{ memberId },
'Triggering member update workflow to refresh affiliations.',
)
await signalMemberUpdate(temporal, memberId)
}
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