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

[feature request]: Get contributors data from Github API #11

Closed
2 tasks done
ashutoshkrris opened this issue Oct 6, 2021 · 29 comments · Fixed by #14
Closed
2 tasks done

[feature request]: Get contributors data from Github API #11

ashutoshkrris opened this issue Oct 6, 2021 · 29 comments · Fixed by #14
Assignees

Comments

@ashutoshkrris
Copy link
Owner

Is there an existing issue for this?

  • I have searched the existing issues.

Describe the feature.

As we are building a contributors page, we need data of contributors.

Problem/Motivation.

As people are gradually contributing to the project, we must be thankful for their efforts.

Possible Solution/Pitch.

There are two approaches :

  1. Use a JSON file such as contributors.json and then using Javascript, we can make use of that data.
  2. Use Github API to get the list of contributors and their details to directly serve it from backend.

Anything else?

Since some bots such as dependabots can be found in the contributors' list. So, while using Github API, make sure you exclude them.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

hey @ashutoshkrris. I would like to work on this issue

@ashutoshkrris
Copy link
Owner Author

Sure @Tawishi , go ahead!

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

I am able to fetch the contributors, excluding the bot, using the Github API
where do we want these to be added in the backend?

@ashutoshkrris
Copy link
Owner Author

you can create a file called contributors.py within the core package @Tawishi
also, if possible use Github access tokens to increase the number of requests

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

ok @ashutoshkrris

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

@ashutoshkrris what data is needed out of this?

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

@ashutoshkrris
Copy link
Owner Author

ashutoshkrris commented Oct 6, 2021

From this API, the avatar_url and html_url would be fine. Also, there is some other API to fetch user details such as it's name. Can we use that to get the contributor's name? @Tawishi

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

ok, so getting the avatar_url and html_url is done
looking for a way to get the contributor's name

@ashutoshkrris
Copy link
Owner Author

This API might be useful : https://api.github.com/users/{username}

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

this works @ashutoshkrris
we have the avatar_url html_url and name now
so contributors.py has 2 functions -

  • for getting contributors avatar_url, html_url, github username
  • for getting name of contributor using github username

@ashutoshkrris
Copy link
Owner Author

We're making use of GITHUB API TOKENS in the headers, right?

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

almost forgot that. working on it

@ashutoshkrris
Copy link
Owner Author

Hey @Tawishi
Head over to #13 and let's discuss this

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

i got the answer in the docs that is why I removed the comment @ashutoshkrris
Thank you for the update, anyways

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

we will use whose personal token here?

@ashutoshkrris
Copy link
Owner Author

You can create one for yourself and try with that.
Make sure, you don't commit that. You can put that in the .env file
For the project deployment, I'll use mine

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

what should the data be returned as, any specific return type of the required contributor information like JSON, etc.?

@ashutoshkrris
Copy link
Owner Author

you can just return a python dictionary from your function or method.

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

ok

@ashutoshkrris
Copy link
Owner Author

you can return like this :

result = {
    "username": username,
    "name": name,
    "profile_url": html_url
}
return result

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

we have a list of contributors, so a list of such dictionaries? or how do you suggest I represent multiple contributors?

@ashutoshkrris
Copy link
Owner Author

Oops, forgot that.
In that case, you can return something like :

contributors = [
    {
        "name": "Contributor 1",
        "username": "contri1",
        "profile_url": "https://github.com/contri1/"
    },
    {
        "name": "Contributor 2",
        "username": "contri2",
        "profile_url": "https://github.com/contri2/"
    }
]
return contributors

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

all done. I will create a PR
Please ping here in case changes are needed.

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

does this need any documentation update?

@ashutoshkrris
Copy link
Owner Author

Nope, I don't think so as the user need not perform any extra step for getting added as contributors

@Tawishi Tawishi mentioned this issue Oct 6, 2021
5 tasks
@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

@ashutoshkrris checks are failing. Could you please check if any changes are needed from my end?

@ashutoshkrris
Copy link
Owner Author

There were some minor bugs in the workflows.
Need not worry about them

@Tawishi
Copy link
Contributor

Tawishi commented Oct 6, 2021

Thank you @ashutoshkrris for your sypport and patience

@ashutoshkrris
Copy link
Owner Author

ashutoshkrris commented Oct 6, 2021

Thanks for contributing @Tawishi
Feel free to add more features, and create issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants