-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
New filter option for CommitActivity #9215
Comments
Do you have a proposed implementation for this? I think the difficulty is that we'd ideally want the user param to take github username (e.g: Can you see a way of doing it with a single request? |
I looked for a way to do that with a single request, here is my insight:
|
Counting https://api.github.com/repos/badges/shields/commits?author=jNullj works for contributors who have only made a handful of commits. It falls down for users who have made lots though. For example if I call https://api.github.com/repos/badges/shields/commits?author=chris48s it returns 30 commits because the response is paginated. I have made many more than 30 commits to this repo. That said, there is another pattern that can help us here 💡 If we call a GH rest endpoint with shields/services/github/github-contributors.service.js Lines 39 to 45 in 150334b
So far so good. Doing that brings up another interesting question though.. As far as I can tell, there are two possible queries we can make here. If I look at my own contributions for this repo
tells me I am the author of 496 commits
tells me I am the committer of 255 commits Neither of those is the same number reported on https://github.com/badges/shields/graphs/contributors though, and the number on https://github.com/badges/shields/graphs/contributors is also not those two added together 🙃 I think probably most people's expectation would be that this badge would report the same number of commits as the contributors page for their repo and I can see it being a common support question if we were to add this based on |
The Personaly when i think about who made the commit what comes to mind is the person who wrote it, the author. But i understand this could be confusing, i suggest adding a new field with a combobox, something like commiterFilterType which defaults to author. About the https://github.com/badges/shields/graphs/contributors page, The link to the commits in that page for each user links to the commits filtered by author and not commiter.... but i could also see as you mentioned that it isn't the same as the api call returns. I was able to learn from the docs that they count from master/main and gh-pages, but when i tried to use git to test that it still didn't add up... also rebase might effect this as well. notice the small info about rebase... |
I think author is the conceptually right number. Looking into this a bit more, another important difference is going to be that counting the commits by author includes merge commits, whereas the contributors page excludes merge commits. I think I'm happy to just go ahead an implement this based on
{
repository(owner: "badges", name: "shields") {
object(expression: "master") {
... on Commit {
history(author: {id: "MDQ6VXNlcjYwMjU4OTM="}) {
totalCount
}
}
}
}
} It seems like the contributors page is the outlier here 🤷 and it looks like there is no API query we can make that is going to report same number. |
LGTM, I offer writing that if you would like the helping hand, altho this is small and I don't code for a living so I hope to live to the project standard. |
You seemed to do OK in #9196 I believe in you 😄 |
Add a new filter option to [GithubCommitActivity], allowing users to filter the commit activity by a specific author. To make the filter more explicit, The label display "commits by [author]" for the total amount of commits and "commit activity by [author]" for other intervals when an author filter is selected. To maintain a clear and organized code structure, The filtered author is added as an argument and not to the shield path. The request to find the number of commits by the author is made using the REST api rather then the GraphQL api to make it in 1 request rather then 2. Resolves badges#9215
Add a new filter option to [GithubCommitActivity], allowing users to filter the commit activity by a specific author. To make the filter more explicit, The label display "commits by [author]" for the total amount of commits and "commit activity by [author]" for other intervals when an author filter is selected. To maintain a clear and organized code structure, The filtered author is added as an argument and not to the shield path. The request to find the number of commits by the author is made using the REST api rather then the GraphQL api to make it in 1 request rather then 2. Resolves badges#9215
* feat: Add author filter option for CommitActivity Add a new filter option to [GithubCommitActivity], allowing users to filter the commit activity by a specific author. To make the filter more explicit, The label display "commits by [author]" for the total amount of commits and "commit activity by [author]" for other intervals when an author filter is selected. To maintain a clear and organized code structure, The filtered author is added as an argument and not to the shield path. The request to find the number of commits by the author is made using the REST api rather then the GraphQL api to make it in 1 request rather then 2. Resolves #9215 * fix: solve eslint errors * Add tests for [GithubCommitActivity] filter by author Add tests for the new filter by author feature. * update [GithubCommitActivity] spec file for new author feat Add test for new transformAuthorFilter function of GithubCommitActivity added for the author filter feature. * Fix null string for label of GithubCommitActivity * Update GithubCommitActivity example * improve error handeling for GithubCommitActivity The author filter error handling removed was redundent as it would never execute, there is no way to seperate branch not found from repo not found. * update depricated functions PR #9233 replaced errorsMessages with httpErrors. This commit updates the new changes to stay up to date with that PR * remove test for nonexisting error this exception was removed in commit 9e358c8 and is not needed anymore * Fixed test for commit activity unexisting repo * Update example for GithubCommitActivity Picked a user with commits in the repo as an example that would work * Add test for invalid commit activity branch Add test for REST API calls in commit activity branch --------- Co-authored-by: jNullj <jNullj@users.noreply.github.com>
📋 Description
I would like to show my commit activity in a specific repo on my github profile readme using a shield.
To do that i want to modify the comit activity shield to enable filtering by user.
I suggest the label to read "commits by [user]" for total amount and "commit activity by [user]" for anything else (only if a user filter is selected).
I think that adding the filtered username to the path will be confusing as commit activity already includes the repo's owner in the path. I suggest adding it in an argument.
Here i present my vision with examples:
"https://img.shields.io/github/commit-activity/m/eslint/eslint?userFilter=exampleUser"
"https://img.shields.io/github/commit-activity/t/eslint/eslint?userFilter=exampleUser"
i suggest to modify the UI as follows:
I recently added total commits to the commitActivity shield and i don't mind adding this as well if you will have me.
I opened an issue to discuess those changes first please let me know if this looks alright and aligns with the project's goals.
The text was updated successfully, but these errors were encountered: