Skip to content

chore: optimize query members to merge#4154

Draft
joanagmaia wants to merge 4 commits into
mainfrom
chore/optimize-query-members-to-merge
Draft

chore: optimize query members to merge#4154
joanagmaia wants to merge 4 commits into
mainfrom
chore/optimize-query-members-to-merge

Conversation

@joanagmaia
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Conventional Commits FTW!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Optimizes the findMembersWithMergeSuggestions repository queries by introducing a top_candidates CTE that pre-limits memberToMerge to the top 5000 rows by similarity/activityEstimate, and makes the LLM model id configurable for the member merge LLM workflow.

Changes:

  • Add a top_candidates CTE with LIMIT 5000 to both the count and row queries for member merge suggestions in memberRepository.ts, and move similarity IS NOT NULL into the CTE.
  • Make IProcessMergeMemberSuggestionsWithLLM.modelId optional and default it to LlmModelType.CLAUDE_SONNET_4 in mergeMembersWithLLM (replacing the hardcoded model string).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
backend/src/database/repositories/memberRepository.ts Adds top_candidates CTE pre-limit to count and list queries for member merge suggestions.
services/apps/merge_suggestions_worker/src/workflows/mergeMembersWithLLM.ts Reads modelId from workflow args, defaulting to LlmModelType.CLAUDE_SONNET_4.
services/apps/merge_suggestions_worker/src/types.ts Adds optional modelId to IProcessMergeMemberSuggestionsWithLLM.

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

Comment on lines +256 to +262
WITH top_candidates AS (
SELECT "memberId", "toMergeId", similarity, "activityEstimate"
FROM "memberToMerge"
WHERE similarity IS NOT NULL
ORDER BY similarity DESC, "activityEstimate" DESC
LIMIT 5000
)
Comment on lines +374 to +380
WITH top_candidates AS (
SELECT "memberId", "toMergeId", similarity, "activityEstimate"
FROM "memberToMerge"
WHERE similarity IS NOT NULL
ORDER BY similarity DESC, "activityEstimate" DESC
LIMIT 5000
)
FROM "memberToMerge"
WHERE similarity IS NOT NULL
ORDER BY similarity DESC, "activityEstimate" DESC
LIMIT 5000
@joanagmaia joanagmaia changed the title Refs/heads/chore/optimize query members to merge chore: optimize query members to merge May 29, 2026
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