-
Notifications
You must be signed in to change notification settings - Fork 65
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
WIP: Fetch contributions from GitHub API #44
Conversation
✅ Deploy Preview for parthmittal ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Hello this is my initial commit to solve the issue, it is not complete but it gives something close to the desired output. At the moment this is a minimum code just to grasp the possibility and have a better understanding. Here one of the objects it outputs from the array: {
"id": 1599432588,
"organization": "mittal-parth",
"logo": "https://github.com/mittal-parth.png",
"repo": "personal-portfolio",
"type": "pull-request",
"status": "merged",
"title": "Add footer credit notes",
"link": "https://github.com/mittal-parth/personal-portfolio/pull/43",
"number": "#43",
"date": "2023-02-25T00:13:13Z",
"linesAdded": "",
"linesRemoved": ""
} Somethings that I'd like to discuss:
Click to expand.
|
Hi @mateusabelli Looks good. Few things:
About this, I came across this issue on another project of mine. Turns out, that |
Hello @mittal-parth thank you for the feedback!
Yea that was it. I don't think there would be problems fetching from separated endpoints other than the extra request. I feel like it could make the code more readable if we opt to use different endpoints instead of separating them with GET https://api.github.com/search/issues?q=is:pr+author:<username>
GET https://api.github.com/search/issues?q=is:issue+author:<username>
Nice it's okay, I'll be looking into this throughout the week as well. It's something that caught me off guard as I only referenced a small PR with a single commit while studying the
That's interesting, if time allows me I'm going to study the |
|
Hello @mittal-parth. With this update I've merged this branch with my second PR that fixes NPM and
There a few things I'd like to discuss. The first one is that it was not necessary to install the dotenv like I mentioned before, Vite can handle environment variables by itself, however for the GH token it needed to be exposed to the app with I've used the At the moment the data fetching is only getting the first 12 latest contributions without excluding your own repos or own organizations. The filter to switch between organizations is still not implemented yet. Please let me know how do you feel about it so far. |
Hi @mateusabelli! Looks great! I don't think we should limit it to 12. The code restricting it shouldn't be the case. If they'd like, they could do it themselves. Rest is great Vite environment variables shouldn't be an issue. We can probably add a section in the readme which specifies the usage. If they'd like to use Netlify, they can go ahead with putting the environment variable there, otherwise use dotenc. |
Hello @mittal-parth to exclude user owned repository was very simple, but for the user owned organizations it will be a bit more difficult because of how github tags the user depending on their relationship with the org/repo. For example, I've seen this property
There might be more, but with this alone it's tricky to determine if the organization is owned by the user or if the user is just a member of it. I thought about a workaround that would be to have in the constants folder along side the contributions.js a json file "ignore.json" that could be used similar to a gitignore to exclude any organizations or projects that the user wouldnt want to show up. Another thing that I'd like to discuss, is the fact that the GitHub API seems perform the search only within 1 year period. Any contributions older than a year won't show up, so contributions like zulip/zulip#19760 do not appear when fetching. Please let me know what do you think. |
Hi @mateusabelli! Which orgs to hide could be tricky because of a slightly abstract definition of an 'open source contribution'. I would argue that if I am an owner or a collaborator, it wouldn't be an open source contribution. But there are very large open source orgs and being an owner/collaborator there would still mean an open source contribution. Probably, giving the user the choice would be the best way I believe (using the method you mentioned)
Are you sure about this? I couldn't find this documented anywhere as such. Could it be pagination because the API returns the results paginated? |
Hello @mittal-parth Thanks! With this update I've added the missing organization filter and also added the ignore feature. When one these conditions are met the contribution is skipped and won't show up. pulls.items.forEach((pr) => {
const {organization, repo, logoUrl} = parseOriginFromUrl(pr.url)
const isIgnored = ignore.find((item) => (item.toLowerCase() === organization.toLowerCase()))
if (pr.author_association === "OWNER" || isIgnored) {
return
}
...
}
This was a wild guess because older contributions were not showing up, but I'm still looking up for documentation on this subject, I also think it could be some sort of pagination or maybe it needs another search query to allow deeper results. Please let me know what do you think. |
Closes #29