Skip to content

Weight language statistics by repository size - #38

Draft
max-wittig with Copilot wants to merge 2 commits into
mainfrom
copilot/consider-project-size-in-statistics
Draft

max-wittig with Copilot wants to merge 2 commits into
mainfrom
copilot/consider-project-size-in-statistics

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Every project currently counts the same in the overall language percentage, so a 10-line repository has the same weight as a 10,000-line one.

GitLab's languages API still returns only percentages, not per-language line counts. Those percentages are now weighted by the project's precomputed statistics.repository_size. Absolute byte or line counts are used directly when a payload includes them.

  • Weighting
    • Default is repository_size: overall share is sum(percentage * size) / sum(size).
    • --weight equal keeps the previous per-project average.
    • A missing size counts as 1 byte and is reported on projects_missing_size_total.
    • repository_size_bytes_total is the sum of sizes actually used.
  • Lookup and cache
    • Size comes from project statistics already on the object, otherwise one statistics request.
    • Group scans request statistics on the existing project fetch.
    • --cache stores the size next to language data and reuses it until last_activity_at changes.
    • Statistics need the Reporter role. Without it, those projects fall back to 1 byte.
gitlab-languages                  # weight by repository size
gitlab-languages --weight equal   # previous unweighted average

Co-authored-by: max-wittig <6639323+max-wittig@users.noreply.github.com>
Copilot AI changed the title [WIP] Update metrics calculation to consider project size Weight language statistics by repository size Oct 14, 2026
Copilot AI requested a review from max-wittig October 14, 2026 17:17

This branch has not been deployed

No deployments
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.

Consider project size in overall statistics

2 participants