beatty / rustaceanrank

MIT License
4 stars 4 forks source link

Contribution levels from Git #1

Open markrmullan opened 3 years ago

markrmullan commented 3 years ago

"Ideally contribution level from git would be used. I think this would be 10x the work."

Damn, talk about a perfect hook. You really know how to get an engineer to work on a problem. You should consider starting a tech company, or something 😉

This might not be too difficult. It looks like crates.repository specifies a full repository URL such as https://github.com/rust-lang/rust. In that example, rust-lang is the owner and rust is the repository, which should be easily parseable, especially for throwaway code.

From there it would just be a GET https://api.github.com/repos/{owner}/{repository}/contributors. The easiest way to authenticate would be using Basic Authentication. For GH, just concat your username:password, base64 encode it, and throw it in an Authorization header. e.g.,

curl --location --request GET 'https://api.github.com/repos/beatty/rustaceanrank/contributors' \
--header 'Authorization: Basic: base64(markrmullan:scrubbed)'

[
    {
        "login": "beatty",
        "id": 101126,
        "node_id": "MDQ6VXNlcjEwMTEyNg==",
        "avatar_url": "https://avatars.githubusercontent.com/u/101126?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/beatty",
        "html_url": "https://github.com/beatty",
        "followers_url": "https://api.github.com/users/beatty/followers",
        "following_url": "https://api.github.com/users/beatty/following{/other_user}",
        "gists_url": "https://api.github.com/users/beatty/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/beatty/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/beatty/subscriptions",
        "organizations_url": "https://api.github.com/users/beatty/orgs",
        "repos_url": "https://api.github.com/users/beatty/repos",
        "events_url": "https://api.github.com/users/beatty/events{/privacy}",
        "received_events_url": "https://api.github.com/users/beatty/received_events",
        "type": "User",
        "site_admin": false,
        "contributions": 2
    }
]

A Github contribution includes actions like commenting on a PR and not just commits. The response is sorted in descending order by number of contributions for the repository, which feels awfully convenient for this project. Give it a shot with https://api.github.com/repos/rust-lang/rust/contributors. The bots that massively pad their own commit numbers, such as https://github.com/bors, should be easily identifiable for exclusion. The Gitlab et al. repos would be a different story, SELECT repository FROM crates WHERE repository NOT LIKE 'https://github.com/%' LIMIT 100;, but it feels like Github alone should expand your awesome-human-candidate-pool by quite a bit, if it's worth investing a little more time.

Avatars and everything? You've really undersold your design skills.

beatty commented 3 years ago

thanks mark! didn't know it would be that easy, now I just need to tuck the state away as I crawl. ranked list of crates to crawl makes it faster. conveniently, the 'progress bar' would go up exponentially.

yes, when you can no longer snap your fingers and work magically happens you have to learn and do it all yourself. it's so fun I've written my projects in Python, Kotlin, Go, and Rust, used two different CSS frameworks, and deployed on Netlify, Firebase, and Google Cloud Run. Maybe I can get a job as a full-stack developer somewhere. :)