Fix Cartesian product in contributor metrics - #500
Open
EngCaioFonseca wants to merge 1 commit into
Open
EngCaioFonseca wants to merge 1 commit into
EngCaioFonseca wants to merge 1 commit into
Conversation
Signed-off-by: Caio Fonseca <engcaiofonseca@protonmail.com>
Contributor
|
it would be nice to see this issue demonstrated via a live API response if possible.
CollectOSS doesnt use sqlite. Can you provide more details on how you tested this so the test can be replicated? |
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.
Description
The contributor queries compare commit_comment_ref.cmt_id to itself instead of joining comments to their commits. This matches commits with unrelated comments, inflating contribution counts and causing excessive query work on large repositories.
This PR fixes #
Replace the condition with commits.cmt_id = commit_comment_ref.cmt_id in both the repository and repository-group queries, matching the existing approach in contributors_new().
Notes for Reviewers
Both were verified affecting subqueries using in-memory SQLite fixtures covering exact counts, repository/date filtering, and empty results. The fixtures reproduce the original bug.
Signed commits
Generative AI disclosure
Please select one option:
If AI tools were used, please provide details below:
- What tools were used? GPT 6 Astra
- How were these tools used? Running an "audit" (for my own knowledge, deepening my knowledge on collectoss), exploratory investigation into CollectOSS and potential for optimizations.
- Did you review these outputs before submitting this PR? Yes.