ghuser-io / ghuser.io

:octocat: Better GitHub profiles
https://ghuser.io
MIT License
809 stars 47 forks source link

Calculations for Earned Stars, Badges, and Ranking #156

Closed brillout closed 5 years ago

brillout commented 5 years ago

This issue explains how we determine stuff.

Leave a comment for ideas, feedback and objections. We are definitely open for improvements.

Contrib Badge

The contrib badge shows how much you have contributed to the repo.

What contrib badge you get (crown, gold, silver, or bronze) is based on the number of commits you have done. (We want to change that to the number of "user commit days" in the future.)

Calculation details
Whether you get a crown, gold medal, silver medal, or a bronze medal is determined by the following: ~~~js function getContribType(userCommitsCount, userCommitsPercentage, totalCommitsCount) { const THREADSHOLD_CROWN = 0.1; const THRESHOLD_GOLD = 50; const THRESHOLD_SILVER = 5; const contribType = ( userCommitsCount > 1 && (totalCommitsCount * THREADSHOLD_CROWN <= 1 || userCommitsPercentage >= THREADSHOLD_CROWN) && ( 'contrib_crown' ) || userCommitsCount > THRESHOLD_GOLD && ( 'contrib_gold' ) || userCommitsCount > THRESHOLD_SILVER && ( 'contrib_silver' ) || ( 'contrib_bronze' ) ); return contribType; } ~~~

Earned stars

On ghuser.io users can earn stars.

The amount of stars you earn depends on what contrib badge (see above) you have.

Calculation details
How many stars a user earns is determined by the following: ```js const earnedStars_bronze = Math.min(10, Math.floor(0.5*stars)); const earnedStars_silver = Math.max(earnedStars_bronze, Math.min(100, Math.floor(0.1*stars))); const earnedStars_gold = Math.max(earnedStars_silver, Math.floor((userCommitsPercentage/100)*stars)); const earnedStars_maintainer = stars; ```

Repo scale badge

The repo scale badge shows how big a repo is.

The badge is based on how many commits the repo has. (We want to change that to the number of "user commit days" in the future.)

Calculation details
The repo scale badge is determined by the following: ~~~js function getRepoScale(totalCommitsCount) { const THREADSHOLD_LARGE = 2000; const THREADSHOLD_MEDIUM = 500; const THREADSHOLD_SMALL = 50; const repoScale = ( totalCommitsCount > THREADSHOLD_LARGE && 'large' || totalCommitsCount > THREADSHOLD_MEDIUM && 'medium' || totalCommitsCount > THREADSHOLD_SMALL && 'small' || 'micro' ); return repoScale; } ~~~

Ranking

The contributions on a ghuser.io Profile page are sorted according to the contribution score.

Calculation details
The contribution score is based on: - Mainly the number of commits the user has done to the repo. (We want to change that to the number of "user commit days" in the future.) - A star boost that increases the score depending on how many stars the repo has - A contrib boost that increases the score depending on how collaborative the repo is The exact calculation is: ~~~js function getContribScore(userCommitsCount, userCommitsPercentage, stars) { const starBoost = getStarBoost(stars); const contribBoost = getContribBoost(userCommitsPercentage); const contribScore = userCommitsCount*starBoost*contribBoost; return contribScore; } function getContribBoost(userCommitsPercentage) { const contribBoost = 1 + ((1 - userCommitsPercentage) * 5); return contribBoost; } function getStarBoost(stars) { const MAX_STARS = 100*1000; const starBoost = 0.2 + (Math.log10(stars) / Math.log10(MAX_STARS) * 5); return starBoost; } ~~~
Ishaan28malik commented 4 years ago

Great, thanks for sharing this.