Skip to content

Fix Cartesian product in contributor metrics - #500

Open
EngCaioFonseca wants to merge 1 commit into
chaoss:mainfrom
EngCaioFonseca:fix/contributor-metrics-cartesian-product
Open

EngCaioFonseca wants to merge 1 commit into
chaoss:mainfrom
EngCaioFonseca:fix/contributor-metrics-cartesian-product

Conversation

@EngCaioFonseca

@EngCaioFonseca EngCaioFonseca commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Please include a summary of the change.

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

  • Yes, I signed my commits.

Generative AI disclosure

Please select one option:

  • This contribution was NOT assisted or created by Generative AI tools.
  • This contribution was assisted or created by Generative AI tools.

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.

Signed-off-by: Caio Fonseca <engcaiofonseca@protonmail.com>
@MoralCode MoralCode added the API Related to metrics API's label Sep 29, 2026
@MoralCode

Copy link
Copy Markdown
Contributor

it would be nice to see this issue demonstrated via a live API response if possible.

in-memory SQLite fixtures

CollectOSS doesnt use sqlite. Can you provide more details on how you tested this so the test can be replicated?

@MoralCode MoralCode added this to the v1.2 milestone Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Related to metrics API's

Projects

Development

Successfully merging this pull request may close these issues.

2 participants