Skip to content

feat(support): include classic ref-code relationships in recommendation network graph#3897

Closed
Blume1977 wants to merge 1 commit into
developfrom
feat/support-referral-network-usedref
Closed

feat(support): include classic ref-code relationships in recommendation network graph#3897
Blume1977 wants to merge 1 commit into
developfrom
feat/support-referral-network-usedref

Conversation

@Blume1977

@Blume1977 Blume1977 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

The compliance recommendation network graph (getRecommendationGraph) and the recommendation panel read only the Recommendation table. The classic ref-code relationship (user.usedRefuser.ref) is invisible there, even though it:

  • drives AML (InvalidKycStatusRefUser is evaluated against getRefUser(user.usedRef)), and
  • drives ref rewards.

This is not an edge case: ~14,997 userDatas have a real usedRef, of which ~92% have no Recommendation row. A user onboarded via a ref code therefore appears as an isolated node in the network even when AML flags the referral.

Concrete example

userData 330009 used ref code 171-364 (owner: userData 321067, kycStatus = Check) → AML flagged InvalidKycStatusRefUser, but the network graph showed 330009 isolated. The referrer 321067 itself reaches 47 ref-code children but only 13 show up in the graph today (recommendation rows only).

Change

  • Traverse user.usedRef in both directions during the graph BFS (up via getRefUsersByRefs, down via new getUsersByUsedRefs).
  • Emit ref-code edges with kind: UsedRef and the refCode; dedupe against recommendation edges per directed userData pair (confirmed recommendations also write usedRef, so recommendation wins to avoid double edges).
  • Keep the global MAX_NODES = 500 safety cap; full expansion within it.
  • Expose refUserDataId on user support info so the panel can link to the referrer.
  • Index user.usedRef (migration) for the reverse lookup.

Verification

Validated against production data via the debug endpoint:

  • 321067 dedup math: 13 recommendation + 47 ref-code children, 12 overlapping → 48 distinct children, no doubled edges, 330009 included as a ref-code edge.

Notes

PR Completeness

  • Migration (index on user.usedRef)
  • Service/DTO updates
  • Frontend synchronization (paired services PR)

…on network graph

The compliance recommendation network graph and panel only read the
Recommendation table, so classic ref-code relationships (user.usedRef ->
user.ref) were invisible even though they drive AML (InvalidKycStatusRefUser)
and ref rewards. Traverse usedRef in both directions during the graph BFS,
emit deduplicated ref-code edges (recommendation wins for shared pairs),
expose the referrer userData id on user support info, and index user.usedRef
for the reverse lookup.
@github-actions

Copy link
Copy Markdown

⚠️ Unverified Commits (1)

The following commits are not signed/verified:

  • 3d21621 feat(support): include classic ref-code relationships in recommendation network graph (Blume1977)
How to sign commits
# SSH signing (recommended)
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true

# Re-sign last commit
git commit --amend -S --no-edit
git push --force-with-lease

@TaprootFreak

Copy link
Copy Markdown
Collaborator

Superseded by #3948, which consolidates this work into a single PR per repo (per maintainer request). #3948 contains the classic ref-code edges from here plus the recommendation-graph edge-cap fix, the lazy 1-hop neighbor expansion (replacing the full-network load), and 100% unit-test coverage of the new endpoints/helpers. Closing in favor of #3948.

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