chore: optimize query members to merge#4154
Draft
joanagmaia wants to merge 4 commits into
Draft
Conversation
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>
Contributor
There was a problem hiding this comment.
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_candidatesCTE withLIMIT 5000to both the count and row queries for member merge suggestions inmemberRepository.ts, and movesimilarity IS NOT NULLinto the CTE. - Make
IProcessMergeMemberSuggestionsWithLLM.modelIdoptional and default it toLlmModelType.CLAUDE_SONNET_4inmergeMembersWithLLM(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.