Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 19, 2021 05:11 pm GMT

Discover your GitHub ranking with Metrics Insights!

Ever wondered how high is ranked your most starred/forked repository across all GitHub? Or whether if you're one of most followed user account ?

Well, this is possible thanks to Metrics Insights!

Preview image

There's also a few additional data, like the number of bytes you've written for each languages you used up until now!

Preview image

Best of it is that you can use Metrics Insights in your browser without any account login nor cookies!

How does it work though?

I'm currently working on Metrics, a project designed to gather data that you can then render as SVG to embed on your GitHub user profile, like below:

Preview image

Currently, there's hundreds of options, including 4 templates and 30 plugins, one of them being the Achievements one:

Preview image

As you can see, some of them include ranking. You may wonder of these are computed? Well it's actually a lot simpler that it may looks, using GitHub GraphQL API and Puppeteer.

The trick is to fetch the number of followers, created repositories of said user, along with their most starred repository and most forked repository.

Then using search GitHub GraphQL API, we can count how many users and repositories are above using the following query (replacing each $ prefixed values with what we found earlier):

query AchievementsRanking {  repo_rank:search(query: "stars:>$stars", type: REPOSITORY, first: 0) {    repositoryCount  }  user_rank:search(query: "followers:>$followers", type: USER, first: 0) {    userCount  }  forks_rank:search(query: "forks:>$forks", type: REPOSITORY, first: 0) {    repositoryCount  }  created_rank:search(query: "repos:>$created", type: USER, first: 0) {    userCount  }}

As you can see, we only retrieve the total count of each categorie, we don't even try to fetch any content. So basically, if an user has 100 followers and user_rank.userCount send back 999 users, we can deduce that user is 1000th (999+1) since 999 users has more followers. We do the same for each categorie.

One thing to note is that GitHub API may return incomplete count below some thresholds as there's too many results to compute for even GitHub to handle it. But if you have created a respository at least once, or having a repository which has been starred 5+ times or forked 1+ time or if you have 3+ followers, you can compete within each categorie !

I guess it also means that there's a lot of inactive users and unused account, so if you're somewhat active on GitHub you'll be able to see your stats pretty easily with this tool.

Since it's not possible to estimate how many repositories and users exists through GitHub's own API, you may wonder how I got total repositories and users count?

Well, actually these are displayed on GitHub search:

GitHub search

This is why we needed puppeteer We just crawl a few times (displayed stats is random between users, repositories and issues) and extract these. Once we got each categorie at least once, no more need for puppeteer, we're ready to go!

If you're interested, don't hesitate to take a look at this project source code and support it. There's even a plugin to update your profile readme with your latest post from dev.to!

GitHub logo lowlighter / metrics

An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere!

You can provide some feedback like bug reports and suggestion for this feature on GitHub discussions

Thanks a lot for reading, and don't hesitate to share your scores in comments section!

One last bonus: can you guess who is the most followed GitHub user? Click here to know!


Original Link: https://dev.to/lowlighter/discover-your-github-ranking-with-metrics-insights-dpe

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To