Skip to content

fix: never let the 1970 placeholder win a member merge joinedAt - #5351

Merged
themarolt merged 2 commits into
mainfrom
fix/issue-966-member-joinedat-placeholder
Nov 15, 2026
Merged

themarolt merged 2 commits into
mainfrom
fix/issue-966-member-joinedat-placeholder

Conversation

@themarolt

Copy link
Copy Markdown
Contributor

Summary

Merging two members could set the survivor's joinedAt to 1970-01-01, the placeholder integrations use for activities without a date (for example Slack channel members). membersMerge kept the earlier date through getEarliestValidDate, which skipped an old placeholder but accepted an incoming one and kept it as the earliest. The merge now uses the rule data-sink-worker already uses (#5157): a date within five days of the epoch, or an invalid one, never wins.

Changes

  • getEarliestMemberJoinedAt moves from data_sink_worker/src/service/member.service.ts to @crowd/common_services (common.member.service.ts) unchanged.
  • CommonMemberService.membersMerge uses it for joinedAt. Values are wrapped in Date, because the backend passes strings.
  • data-sink-worker's member.service.ts and activity.service.ts import it from @crowd/common_services.
  • getEarliestValidDate is removed from @crowd/common; nothing else used it.

Checked by calling membersMerge with:

  • the ticket's case: A 2022-06-01, B 1970-01-01 → keeps 2022-06-01;
  • the reverse → 2022-06-01;
  • two real dates → the earlier one;
  • a date within five days of the epoch → ignored;
  • string values → 2022-06-01;
  • a missing incoming date → unchanged.

Deploy: data-sink-worker plus the services that merge members through CommonMemberService (backend api, entity-merging-worker, and the other workers that use @crowd/common_services).

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

Related issue

Closes linuxfoundation/lfx-cdp-insights-ops#966

Member merges kept the earlier joinedAt through getEarliestValidDate, which
accepted an incoming 1970-01-01 placeholder (activities without a date, such as
Slack channel members) and kept it as the earliest. The merge now uses the same
rule as data-sink-worker, moved to @crowd/common_services as
getEarliestMemberJoinedAt, and getEarliestValidDate is removed.

Closes linuxfoundation/lfx-cdp-insights-ops#966

Signed-off-by: Uroš Marolt <uros@marolt.me>
Copilot AI balanced review requested due to automatic review settings November 15, 2026 17:55
@cursor

cursor Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes shared member-merge logic for joinedAt across API and workers; behavior is narrower and aligned with ingest, but incorrect deployment could leave inconsistent merge rules between services.

Overview
Member merges no longer pick 1970-01-01 (and other epoch-placeholder joinedAt values) as the survivor’s join date when a real date exists. CommonMemberService.membersMerge now uses getEarliestMemberJoinedAt—the same rule the data-sink worker already applied—instead of getEarliestValidDate, which could treat an incoming placeholder as the earliest date.

getEarliestMemberJoinedAt is moved from data_sink_worker’s member.service into @crowd/common_services (common.member.service.ts) unchanged; activity.service and member.service import it from there. getEarliestValidDate is removed from @crowd/common (timing.ts), including the unused moment-timezone usage tied to that helper.

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

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR shares getEarliestMemberJoinedAt between member merges and the data-sink worker.

  • Member merges keep real join dates over epoch placeholders.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

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.

🟢 Approval recommended

No active review issues are recorded for the joined-date merge changes.

No open issues 🎉

What changed in this PR

This PR prevents epoch-placeholder dates from replacing a real member joinedAt during merges, aligning shared merge behavior with the data-sink worker.

Changes:

  • Moves the existing joined-date helper unchanged into @crowd/common_services.
  • Uses the helper during member merges, converting inputs to Date to support string values.
  • Updates worker imports and removes the obsolete getEarliestValidDate helper.
File Description
services/​libs/​common/​src/​timing.ts Removes the obsolete date helper and its Moment import.
services/​libs/​common_services/​src/​services/​common.member.service.ts Hosts the shared helper and applies it to merged joinedAt values.
services/​apps/​data_sink_worker/​src/​service/​member.service.ts Imports the shared helper instead of defining it locally.
services/​apps/​data_sink_worker/​src/​service/​activity.service.ts Imports the helper from @crowd/common_services.

Review effort: Balanced

…joinedat-placeholder

Signed-off-by: Uroš Marolt <uros@marolt.me>
Copilot AI balanced review requested due to automatic review settings November 15, 2026 18:40

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.

🟢 Approval recommended

No active review issues are reported for the shared joinedAt date-selection changes.

No open issues 🎉

Review effort: Balanced

@themarolt
themarolt merged commit cfbe8bd into main Nov 15, 2026
15 checks passed
@themarolt
themarolt deleted the fix/issue-966-member-joinedat-placeholder branch November 15, 2026 18:45
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.

2 participants