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

fix(profile): use affiliation=own to get user repos #281

Merged
merged 1 commit into from Sep 1, 2017

Conversation

blakegong
Copy link
Contributor

Problem

The number of repositories on your own profile page is the same as shown on github.com, which is
(user.public_repos + user.total_private_repos). However, when the button is clicked, the repository list actually shows all the repositories where you have admin permission. The delta here as I observed, is the repositories in a private organization you are part of where you are also granted admin permission to.

image

Another minor issue is the current way of querying extra data then filter in client is inefficient compared to querying the exact data that the client actually wants:

fetchUrl(`${url}/repos?per_page=50`, accessToken)
.then(data => {
const payload = isAuthUser
? data.filter(repo => repo.permissions.admin)
: data;

Approach

This PR uses affiliation=own from https://developer.github.com/v3/repos/#parameters to get user repos, which provides the exact data needed here. The number of repositories returned in this PR matches the number on user's profile page, which is (user.public_repos + user.total_private_repos).

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no idea there was an affiliation filter we could use! Thanks @blakegong, agreed it makes much more sense to leverage this than to do our workaround 😅

Thanks again <3

@@ -275,6 +275,15 @@
"contributions": [
"code"
]
},
{
"login": "blakegong",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow this is fast! Thanks 😄

@housseindjirdeh housseindjirdeh merged commit 842d062 into gitpoint:master Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants