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

Adds the ability to include data from organization repositories #2459

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

rickstaa
Copy link
Collaborator

This PR replaced #1122. It adds the ability to include data from organization repositories.

@vercel
Copy link

vercel bot commented Jan 24, 2023

@rickstaa is attempting to deploy a commit to the github readme stats Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link

codecov bot commented Jan 24, 2023

Codecov Report

Patch coverage: 92.75% and project coverage change: -0.08 ⚠️

Comparison is base (c96e84a) 97.52% compared to head (522ec4b) 97.44%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2459      +/-   ##
==========================================
- Coverage   97.52%   97.44%   -0.08%     
==========================================
  Files          24       24              
  Lines        4683     4740      +57     
  Branches      430      434       +4     
==========================================
+ Hits         4567     4619      +52     
- Misses        115      120       +5     
  Partials        1        1              
Impacted Files Coverage Δ
src/common/utils.js 99.00% <86.84%> (-1.00%) ⬇️
api/index.js 96.19% <100.00%> (+0.07%) ⬆️
api/top-langs.js 95.74% <100.00%> (+0.09%) ⬆️
src/fetchers/stats-fetcher.js 92.08% <100.00%> (+0.32%) ⬆️
src/fetchers/top-languages-fetcher.js 88.95% <100.00%> (+0.27%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rickstaa rickstaa requested a review from anuraghazra January 24, 2023 10:48
@rickstaa
Copy link
Collaborator Author

@anuraghazra I think it would be nice to merge this after all these years, even if it is only available under an experimental env variable (see #1122 (comment)). I'm happy to add the tests and documentation if you agree.

@@ -36,6 +36,7 @@ export default async (req, res) => {
disable_animations,
border_radius,
border_color,
role,
Copy link
Owner

Choose a reason for hiding this comment

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

well I totally forgot what this ownerAffiliation does, but why does this need to be controlled by the user?

Copy link
Collaborator Author

@rickstaa rickstaa Jan 24, 2023

Choose a reason for hiding this comment

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

They do not. Another option I looked at was to use a include_orgs variable and only add the COLLABORATOR flag. I did this in #2277, but people had problems (see #1 (comment)). For some reason, when you are the creator of a repository, you have to add yourself as a collaborator since github does not do this automatically even though you have contributed to the repository (see #1 (comment)).

In short, due to limitations in the GraphQL API, there currently is no clean way to implement this. The only way to get the language data in all repositories a user contributed is by looping through the commits, which is infeasible given the current GraphQL and Vercel rate limits. 😅 I created a feature request to improve this, but I think it's improbable GitHub will implement this (see community/community#18230 and community/community#36108).

I'm therefore also okay with not merging an organization-related PR at all, but I just thought implementing it as a (hidden) experimental feature might help some people who code most of their projects in organizations. 🤔👍

This commit fixes a small error in the stats-fetcher that caused the
`exclude_repo` parameter values to be seen as the `ownerAffiliation`
inputs.
@alexleboucher
Copy link

Hello, any news for this PR ? Do you think it could be merged soon ?
Thanks !

@rickstaa
Copy link
Collaborator Author

Hello, any news for this PR ? Do you think it could be merged soon ? Thanks !

Hey, @alexleboucher, I can not say when and if it will be merged in the master branch since it still has to be reviewed by @anuraghazra, and both he and I maintain this project in our volunteered free time. However, you don't need to wait, as you can already use this PR by adding it to your fork. I already use it on my README 👍.

@Parth-1612
Copy link

any update?

@rickstaa
Copy link
Collaborator Author

rickstaa commented Mar 6, 2023

any update?

@Parth-1612 unfortunately, we still have to revisit this again. There are problems with both #2459 and #1122 due to how the stats and languages are currently calculated. For example, we currently only fetch the first 100 repositories in both the stats and language cards, so adding the ORG stats in the current form will make the cards less accurate. All of these issues are discussed in the following:

We will likely merge this or #1122 and make the feature available under the new GitHub action if #2179 is finished 👍🏻. You can, however, already use both #2459 and #1122 in your own forks.

@AiroPi
Copy link

AiroPi commented Mar 20, 2024

I just tested the feature by merging the branch into my fork (resolving conflits), but it seems that the OWNER role doesn't work. Only COLLABORATOR and ORGANIZATION_MEMBER 🤷

@qwerty541
Copy link
Collaborator

qwerty541 commented Mar 21, 2024

I just tested the feature by merging the branch into my fork (resolving conflits), but it seems that the OWNER role doesn't work. Only COLLABORATOR and ORGANIZATION_MEMBER 🤷

Just checked your instance. Looks like all works as expected, the stats increases when adding new roles to the query string. I will add an examples below.

OWNER

<img src="https://github-readme-stats-git-master-airopis-projects.vercel.app/api?username=AiroPi&count_private=true&show_icons=true&locale=en&theme=onedark&role=OWNER" />

OWNER + ORGANIZATION_MEMBER

<img src="https://github-readme-stats-git-master-airopis-projects.vercel.app/api?username=AiroPi&count_private=true&show_icons=true&locale=en&theme=onedark&role=OWNER,ORGANIZATION_MEMBER" />

OWNER + ORGANIZATION_MEMBER + COLLABORATOR

<img src="https://github-readme-stats-git-master-airopis-projects.vercel.app/api?username=AiroPi&count_private=true&show_icons=true&locale=en&theme=onedark&role=OWNER,ORGANIZATION_MEMBER,COLLABORATOR" />

@AiroPi
Copy link

AiroPi commented Mar 21, 2024

Ok I may have misunderstood how role is supposed to works then.
Is "OWNER" like a default value if the "role" argument isn't provided ?

Does OWNER means "repo I am the owner of"? Or "repo from organizations I am the owner of"?

@qwerty541
Copy link
Collaborator

Ok I may have misunderstood how role is supposed to works then. Is "OWNER" like a default value if the "role" argument isn't provided ?

Yes, you are right, OWNER is a default value. Here is the code:
https://github.com/anuraghazra/github-readme-stats/pull/2459/files#diff-658a74e9e49cfa0bc40425a3275025795e81f2492c36d010ac2662510044ce0dR444-R447

Does OWNER means "repo I am the owner of"? Or "repo from organizations I am the owner of"?

This means "Repositories that are owned by the authenticated user.". GitHub docs source:
https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation

@alexleboucher
Copy link

Hello, any news for this PR ? Do you think it could be merged soon ?
(yes, I already asked this 15 months ago 😅)

@qwerty541
Copy link
Collaborator

Hello, any news for this PR ? Do you think it could be merged soon ? (yes, I already asked this 15 months ago 😅)

Hey @alexleboucher. Thanks for your interest.

Honestly, I don't think that there will be any new features in the nearest time. Currently I'm alone active from the team and I don't have enought access rights to merge anything without additional approval of another collaborator.

Additionally, this pull request needs to be reworked a bit, abiltiy to include organizarions data should be accessible only on users own instances under environment varoable. Enabling this feature on public instance will cause more often downtimes due to high consumption of GitHub API token points.

Hope on your understanding and patience.

Remember that you can deploy this branch on your own Vercel instance and already use this feature.

@qwerty541 qwerty541 mentioned this pull request Jun 4, 2024
kaiwinut added a commit to kaiwinut/github-readme-stats that referenced this pull request Oct 27, 2024
@kjeon0901
Copy link

kjeon0901 commented Dec 2, 2024

Hi, I have forked the add_role_param repo today and deployed my own Vercel instance with my PAT_1 and it still does not show me my top languages from contributions in organizations to which I am either owner either member. Any idea? (the basic stats are working well, including commit information within organizations)

I am using the following -> URL + /api/top-langs?username={username}&count_private=true&layout=compact&hide_border=true&hide_title=true&theme=transparent&role=OWNER,COLLABORATOR,ORGANIZATION_MEMBER

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.

9 participants