Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language statistics percentages don't add up to 100% #22023

Closed
hr-98 opened this issue Dec 4, 2022 · 3 comments · Fixed by #22026
Closed

Language statistics percentages don't add up to 100% #22023

hr-98 opened this issue Dec 4, 2022 · 3 comments · Fixed by #22026
Labels

Comments

@hr-98
Copy link
Contributor

hr-98 commented Dec 4, 2022

Description

This is probably just a rounding bug, but it is still a little bit frustrating when you notice it.
As you can see from the screenshot, the percentages are
COBOL 45.7%
Assembly 43.2%
Shell 5.9%
Ruby 5.3%
which is 100.1% in total.

I've made a copy of my repo here:
https://try.gitea.io/hr98/aoc22-copy-percentage-bug

Gitea Version

Gitea version 1.17.3 built with GNU Make 4.1, go1.18.7 : bindata, sqlite, sqlite_unlock_notify

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

image

Git Version

git version 2.31.1

Operating System

Linux

How are you running Gitea?

Downloaded the binary and running as systemd service on Alma Linux 9.

Database

SQLite

@hr-98 hr-98 added the type/bug label Dec 4, 2022
@eeyrjmr
Copy link
Contributor

eeyrjmr commented Dec 4, 2022

This is more than likely due to rounding to 1decimal place.
changing it to 2dp would slightly improve it but I doubt this will truly ever be solved due to how floats work and all you need is the perfect combination of odd-count languages detected and odd-count files counted for it to manifest itself at some decimal position

@hr-98
Copy link
Contributor Author

hr-98 commented Dec 4, 2022

There are different things you can do to avoid such problems, like the largest remainder method.
I might try implementing it to where ever it generates the stats later, I've just never used go before.

@delvh
Copy link
Member

delvh commented Dec 4, 2022

Then please have a look at models/repo/language_stats.go#44-67.

lunny pushed a commit that referenced this issue Dec 8, 2022
Fix #22023 

I've changed how the percentages for the language statistics are rounded
because they did not always add up to 100%
Now it's done with the largest remainder method, which makes sure that
total is 100%

Co-authored-by: Lauris BH <lauris@nix.lv>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants