ryo-ma / github-profile-trophy

🏆 Add dynamically generated GitHub Stat Trophies on your readme
https://github-profile-trophy.vercel.app
MIT License
5.18k stars 767 forks source link

On what basis the Experience Trophy is ranked #258

Closed ghost closed 6 months ago

ghost commented 8 months ago

Hi I have been using Github Profile Trophy for almost a year now. But one thing i still didnt catch up is how the Experience Trophy is measured/defined to be a certain rank. Like i know it is not on basis of the period/years I have been on github because my points is 4 but i have joined github on 2022(2 years).

So how the Exp trophy is ranked on what basis...

Thank you

ghost commented 8 months ago

Hope i was clear with my English

TurtleCode84 commented 7 months ago

That's interesting;

I was curious about this too, so I looked into the code and found the class definition for the Experience trophy, and it looks like it is based on your Github account age (certain numbers of years).

However, you should still be at least at "Junior Dev" if the code comments are correct:

https://github.com/ryo-ma/github-profile-trophy/blob/bc4e735c815315ca7abed8c9d79e4bd638daab22/src/trophy.ts#L270-L319

So I'm not entirely sure what's happening in your case, since it seems to be working correctly on my own profile. Maybe another developer could shed some light on this?

ghost commented 7 months ago

Yeah I got it, I joined github in 2022 dec, now its feb of 2024 around a year. So my ranking if 4, 0.5 year is 2 , thus my rank is four as I have been in github for a year. You were very helpful thank you.

: )

TurtleCode84 commented 7 months ago

Happy to help!

Took me a minute to wrap my mind around how the scoring calculations work 😅

But out of curiosity, I looked a bit deeper into how the account age score is calculated, and I may even want to propose a change to one of the threshold scores.

https://github.com/ryo-ma/github-profile-trophy/blob/bc4e735c815315ca7abed8c9d79e4bd638daab22/src/user_info.ts#L84-L89

This code gets the number of milliseconds since the Github account was created, converts milliseconds to days, and then divides by 100, so the number in durationDays now actually represents "hundreds of days."

So in the class definition, which uses durationDays, each rank is assigned at a rounded account age (to the hundreds place), meaning the rank won't immediately reflect when the account is as old as the code comment says.

https://github.com/ryo-ma/github-profile-trophy/blob/bc4e735c815315ca7abed8c9d79e4bd638daab22/src/trophy.ts#L288-L292

For example, a score of 28 actually means 2800 days, about 7.67 years (more than 7.5). Nearly all of threshold values are the closest whole number value to the correct number of days, adjusted. The only one I would change is that of Master Dev, because 37 gives a closer estimate to ten years than 40.

Fascinating stuff!

Yes, I spent time doing this. I have no regrets :)

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 6 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.