anuraghazra / github-readme-stats

:zap: Dynamically generated stats for your github readmes
https://github-readme-stats.vercel.app
MIT License
69.41k stars 22.97k forks source link

[Feature Request] Add organization stats #1

Open franky47 opened 4 years ago

franky47 commented 4 years ago

Most of my open-source work is moved to dedicated organizations (47ng, FortySevenEffects, Chiffre), for scoping and to avoid cluttering my personal repos.

I'd be happy to contribute a feature to include aggregated organization stats.

API ideas:

![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&orgs=acme,evilcorp,fsociety)
brunolnetto commented 1 year ago

You may erase branch master-rstaa. Roger!

brunolnetto commented 1 year ago

@rickstaa It will sound neatly picky, but whatever:

  1. Type brunolnetto on field Username: https://awesome-github-stats.azurewebsites.net/ ;
  2. Go to my profile on github: https://github.com/brunolnetto

You may notice the number of stars is not equal. It makes me wonder the reason, but I am not the right person to solve this issue.

rickstaa commented 1 year ago

@rickstaa It will sound neatly picky, but whatever:

  1. Type brunolnetto on field Username: https://awesome-github-stats.azurewebsites.net/ ;
  2. Go to my profile on github: https://github.com/brunolnetto

You may notice the number of stars is not equal. It makes me wonder the reason, but I am not the right person to solve this issue.

I checked your code and the answer to your question is easy. The tool you gave, https://github.com/brunobritodev/awesome-github-stats, uses the ORGANIZATION_MEMBER RepositoryAffiliation role following (see https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation). I only use the COLLABORATOR and OWNER roles since the GRS team doesn't think people should receive stars of organization repositories to which they did not contribute. You can test this yourself in the GraphQL explorer.

awesome-github-stats GraphQL query

query userInfo($login: String!) {
  user(login: $login) {
    name
    login
    repositories(
      first: 100
      ownerAffiliations: [OWNER, COLLABORATOR, ORGANIZATION_MEMBER]
      orderBy: {direction: DESC, field: STARGAZERS}
    ) {
      nodes {
        name
        stargazers {
          totalCount
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
{
  "login": "rickstaa"
}

Our query

query userInfo($login: String!) {
  user(login: $login) {
    name
    login
    repositories(
      first: 100
      ownerAffiliations: [OWNER, COLLABORATOR]
      orderBy: {direction: DESC, field: STARGAZERS}
    ) {
      nodes {
        name
        stargazers {
          totalCount
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
{
  "login": "rickstaa"
}
brunolnetto commented 1 year ago

You use your cleverness wisely.

TonyTroeff commented 1 year ago

I am owner of the TryAtSoftware organization and I can assure you that stats for the repositories within this organization are not included.

rickstaa commented 1 year ago

I am owner of the TryAtSoftware organization and I can assure you that stats for the repositories within this organization are not included.

@TonyTroeff, thanks for your question. This feature request (i.e. #1) is about including stats from organization repositories for users that have contributed to these repositories. This feature has not yet been released but can be used as explained in https://github.com/anuraghazra/github-readme-stats/issues/1#issuecomment-1329809068. Your stats will be included if you are a collaborator to such a repository when setting the include_orgs variable.

The feature you are asking for, which I presume is organisation/team stats, is tracked in #654. You can show your support there. If enough people show interest in such a card, it will come in our top 10 feature requests, and I will take a look (see https://github.com/anuraghazra/github-readme-stats/issues/1935).

TonyTroeff commented 1 year ago

@rickstaa, i support the idea of #654, but my problem here is different. I own the organization and I have been contributing to all repositories contained there as well (actually I am the only member of the organization and the only contributor until this very moment). However, if I include the include_orgs variable, I do not see the desired changes in my stats

rickstaa commented 1 year ago

@rickstaa, i support the idea of #654, but my problem here is different. I own the organization and I have been contributing to all repositories contained there as well (actually I am the only member of the organization and the only contributor until this very moment). However, if I include the include_orgs variable, I do not see the desired changes in my stats

I see, in that case, the include_orgs variable that is included in the https://github.com/anuraghazra/github-readme-stats/tree/master_orgs branch should show the stats of the contributions you made to your organizations. πŸ€” Please make sure that you are on the right branch.

The include_orgs tag currently works as follows. When enabled, it adds the COLLABORATOR repositoryAffiliation filter to the GraphQL query:

https://github.com/anuraghazra/github-readme-stats/blob/06aee4f12c1f8675d961405d78e841cad40a25ef/src/fetchers/stats-fetcher.js#L25

As explained in GitHubs' GraphQL documentation, this will include repositories of the requested user that are found in organizations. I checked your account using the GraphQL explorer

query userInfo($login: String!) {
  user(login: $login) {
    name
    login
    repositories(
      first: 100
      ownerAffiliations: [OWNER, COLLABORATOR]
      orderBy: {direction: DESC, field: STARGAZERS}
    ) {
      nodes {
        name
        stargazers {
          totalCount
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
{
  "login": "rickstaa"
}

and it looks like the data only shows up when I also add the ORGANIZATION_MEMBER repository affiliation flag. I however don't think adding this flag is wise since it will include stats from all repositories of organizations a user is in. Maybe you can contact GitHub support and explain that you are trying to get the data of repositories you contributed to in an organization you created, but it is not showing your results. It looks like this is a flaw in their API. The easiest way to fix this is to manually add yourself as an organization ADMIN collaborator to all your organization repositories, but I think GitHub should update its API.

brunolnetto commented 1 year ago

@rickstaa I had an idea that might interest us:

Statement: given repositories with tags COLLABORATOR and OWNER, provide a JSON with (key, value) equal to (username, [repository_names]).

rickstaa commented 1 year ago

@rickstaa I had an idea that might interest us:

Statement: given repositories with tags COLLABORATOR and OWNER, provide a JSON with (key, value) equal to (username, [repository_names]).

Hey @brunolnetto, I'm not sure if I follow you. Do you want to request a feature on the GitHub feature request board that might help GRS?

brunolnetto commented 1 year ago

Great idea! Done!

brunolnetto commented 1 year ago

It would be nice to know about unique visitors count on organizations and personal repositories IMHO.

BroFromSpace commented 1 year ago

Hello guys. Could you help me please, I have fork repo run it on vercel in master_orgs branch, however stats from organisation I am working in are not displayed. What could the problem be?

brunolnetto commented 1 year ago

I recommend you to use @rickstaa 's vercel instance until next release. You can check README.md content on either /rickstaa/rickstaa or /brunolnetto/brunolnetto.

BroFromSpace commented 1 year ago

Unfortunately no changes. Is it required to have some settings in github or in organisation?

brunolnetto commented 1 year ago

You have to copy the vercel URL on README.md of above-mentioned repositories and change the property rickstaa or brunolnetto to yours.

BroFromSpace commented 1 year ago

You mean it should be like this https://github-readme-stats-git-masterrstaa-rickstaa.vercel.app/api?username=brofromspace&show_icons=true&include_all_commits=true&count_private=true&include_orgs=true&locale=en?

brunolnetto commented 1 year ago

It is. But I am not sure if include_orgs is already a feature.

Take a look at my repository, reproduce on yours by preview tab usage.

BroFromSpace commented 1 year ago

Yep, but its not working, I see my stats, org stats seems not included.

brunolnetto commented 1 year ago

It occurs oftentimes if you belong to some private organization. There are criteria on organization star collection here. You may fit on one of those.

BroFromSpace commented 1 year ago

Can you share these criterias with me please.

brunolnetto commented 1 year ago

I recommend you to read this post comment and its previous: https://github.com/anuraghazra/github-readme-stats/issues/1#issuecomment-1329809068

brunolnetto commented 1 year ago

@rickstaa it is me again. Now and then, my profile card with profile activity renders broken. Do you have any idea for the reason? In case the feature is official and there is some available common app, may you give us the reference? Thanks, peace.

rickstaa commented 1 year ago

@rickstaa it is me again. Now and then, my profile card with profile activity renders broken. Do you have any idea for the reason? In case the feature is official and there is some available common app, may you give us the reference? Thanks, peace.

@brunolnetto no problem. The card is not broken, but it seems the Vercel function that creates it reaches the GitHub CDN timeouts. The card will, therefore, not show up the first time a user visits your page after the Cache is expired. It, however, shows up for the next user or if you refresh the page. https://github.com/anuraghazra/github-readme-stats/pull/2159 might elevate the problem, but the best solution would be to change to a GitHub action (see https://github.com/anuraghazra/github-readme-stats/issues/2179). I, however currently sadly do not have the time to implement it.

brunolnetto commented 1 year ago

I see. I had this guess in mind because of the refreshing experience on second attempt. You nailed it clearly without my comemnts. πŸ‘πŸ½

brunolnetto commented 1 year ago

Your last comment on given issues depends on codebase conversion to typescript. Friendly question: is there any (good) progress in this direction?

rickstaa commented 1 year ago

Your last comment on given issues depends on codebase conversion to typescript. Friendly question: is there any (good) progress in this direction?

The truth is that I'm currently focusing on my Master's Thesis, so I currently don't have the time to implement these features πŸ˜…. My plan was to look at them after my graduation but feel free to work on them if you want. The most up-to-date PR can be found at https://github.com/anuraghazra/github-readme-stats/pull/2108. A lot has already been done by @HwangTaehyun during the hackathon, but some files still need to be translated to typescript, and some changes that were requested by @anuraghazra still need to be applied. I forgot the exact details of why I wanted the codebase to be translated to TS before implementing https://github.com/anuraghazra/github-readme-stats/pull/2159, but it had something to do with some things requiring a lot more work in plane JS πŸ€”.

brunolnetto commented 1 year ago

Save space for your thesis compilation. :-P

There are familiarization steps before I can put my hands on any feature development. I will take a look at it, but I cannot promise anything: do not await πŸ˜… .

rickstaa commented 1 year ago

Save space for your thesis compilation. :-P

There are familiarization steps before I can put my hands on any feature development. I will take a look at it, but I cannot promise anything: do not await sweat_smile .

Haha, no problem. Don't feel pressured it has become quite a codebase over the years πŸ˜…. If you have some questions feel free to tag me. I'm planning to do it eventually since the problems also occur on my profile, but now I need to headspace for my studies. πŸ‘πŸ»

brunolnetto commented 1 year ago

There is the app headspace already at digital stores. I think you will have to use freemind instead. hehe

rickstaa commented 1 year ago

There is the app headspace already at digital stores. I think you will have to use freemind instead. hehe

Haha, I indeed own that app!🀣 Calm is also a good one πŸ§˜πŸ»β€β™‚οΈ.

JacquelinBB commented 1 year ago

I was able to use the query params mentioned in my last comment to include org repo for top-langs card. Use @franky47's card as demo (since mine was a bit trickyπŸ₯²):

(role=OWNER as default) https://github-readme-stats-one-bice.vercel.app/api/top-langs/?username=franky47&langs_count=10&layout=compact

https://github-readme-stats-one-bice.vercel.app/api/top-langs/?username=franky47&langs_count=10&layout=compact&role=OWNER,ORGANIZATION_MEMBER,COLLABORATOR

?role= could be any combination of repositoryaffiliation enum here: https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation

The bad thing is that when you're using the "COLLABORATOR", it basically includes whether or not you've contributed to someone else's repository.

I had to use exclude_repo to not affect the language progress count, you could also hide the language. It would be good if you could use other parameters, which put this condition, either by commit or interaction!

rickstaa commented 1 year ago

I was able to use the query params mentioned in my last comment to include org repo for top-langs card. Use @franky47's card as demo (since mine was a bit trickyπŸ₯²): (role=OWNER as default) https://github-readme-stats-one-bice.vercel.app/api/top-langs/?username=franky47&langs_count=10&layout=compact https://github-readme-stats-one-bice.vercel.app/api/top-langs/?username=franky47&langs_count=10&layout=compact&role=OWNER,ORGANIZATION_MEMBER,COLLABORATOR ?role= could be any combination of repositoryaffiliation enum here: https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation

The bad thing is that when you're using the "COLLABORATOR", it basically includes whether or not you've contributed to someone else's repository.

I had to use exclude_repo to not affect the language progress count, you could also hide the language. It would be good if you could use other parameters, which put this condition, either by commit or interaction!

@JacquelinBB, thanks for your comment. We are aware of the problems, but this is currently due to the upstream GraphQL API limitation. This problem and more are discussed at https://github.com/anuraghazra/github-readme-stats/issues/1801.

BroFromSpace commented 1 year ago

Hi guys, is there any way to include mine PR's and commits from organisation repos to stats?

mpl1018 commented 1 year ago

We made this based on this issue: https://pullpo.io/products/devcard Pullpo - DevCard

joaovian06 commented 1 year ago

I tried this @mpl1018, but canΒ΄t get any values to my devcard. :(

brunolnetto commented 1 year ago

@mpl1018 I clicked the button "Create my DevCard" and others. It tries to log me in on Slack. It makes no sense to me.

mpl1018 commented 1 year ago

I understand πŸ˜… @joaovian06 @brunolnetto Pullpo started as a product to have code review conversations on ephemeral Slack channels per PR (https://pullpo.io/products/channels). However, we made the bad decision to use Slack for login instead of GitHub. This week, we are allowing users to log in with GitHub as well. I'll keep you updated!

mpl1018 commented 1 year ago

UPDATE: You should now be able to log in with GitHub and install Pullpo for your desired GitHub organization. Your devcard will be available at https://pullpo.io/app/profile. Sorry for the inconveniences πŸ™

Don't worry if your stats appear as zeros; it can take some time to fetch historical data from the organization.

If you want to read about the permissions we ask for, you can check it out at https://docs.pullpo.io/github-permissions. Additionally, here is a tutorial on how to set up the devcard: https://docs.pullpo.io/devcard-requirements. Also feel free to reach out to me at marco@pullpo.io

@brunolnetto @erickskrauch @ketrab2004 @joaovian06 @kavanase

rickstaa commented 1 year ago

UPDATE: You should now be able to log in with GitHub and install Pullpo for your desired GitHub organization. Your devcard will be available at https://pullpo.io/app/profile. Sorry for the inconveniences pray

Don't worry if your stats appear as zeros; it can take some time to fetch historical data from the organization.

If you want to read about the permissions we ask for, you can check it out at https://docs.pullpo.io/github-permissions. Additionally, here is a tutorial on how to set up the devcard: https://docs.pullpo.io/devcard-requirements. Also feel free to reach out to me at marco@pullpo.io

@brunolnetto @erickskrauch @ketrab2004 @joaovian06 @kavanase

@mpl1018, thanks for pointing me to your tool. More platforms to choose from for users is great πŸ‘πŸ». Another provider is https://quine.sh/. Having that said, people can already include organization stats in GRS by deploying their own instance and merging https://github.com/anuraghazra/github-readme-stats/pull/2459. Furthermore, we will release a GitHub version of GRS after this summer that will give users the ability to get more accurate language and stats results, including organization stats (see https://github.com/anuraghazra/github-readme-stats/issues/2179) πŸš€.

brunolnetto commented 1 year ago

Comment: @mpl1018 I would really like to know how you do such convolute software systems. Really! I am unemployed and feel very inadequate not knowing this.

Report : I got stuck on this "alert" pop-up component, which does not work (It may be something on its callback, I guess.)

image

rickstaa commented 1 year ago

Comment: @mpl1018 I would really like to know how you do such convolute software systems. Really! I am unemployed and feel very inadequate not knowing this.

Report : I got stuck on this "alert" pop-up component, which does not work (It may be something on its callback, I guess.)

image

I do not want to be a grinch here, but can we keep the pullpo bug reporting through the site intercom before it becomes a big thread πŸ˜….

image

brunolnetto commented 1 year ago

This is all I hear: grinch, grinch, grinch.

rickstaa commented 1 year ago

This is all I hear: grinch, grinch, grinch.

🀣

grinch-coffee

rickstaa commented 1 year ago

@mpl1018 feel free to answer @francois-rozet's last question here. Just trying to prevent this from becoming a pullpo debug issue since a lot of people are subscribed πŸ˜… .

mpl1018 commented 1 year ago

Hi @francois-rozet! My apologies the inconvenience. The issue should be resolved now. πŸ‘ Btw, to anyone interested, feel free to reach out to me at marco@pullpo.io.

francois-rozet commented 1 year ago

Hey, no problem, but I don't even know why I'm mentioned here :sweat_smile: I guess it is a typo between my handle and the OP's handle.

rickstaa commented 1 year ago

Hey, no problem, but I don't even know why I'm mentioned here sweat_smile I guess it is a typo between my handle and the OP's handle.

Oh, sorry for the noise πŸ˜…. I should not try to answer GitHub issues quickly before shutting down at the end of the day. Should have been @brunolnetto indeed πŸ‘πŸ».

brunolnetto commented 1 year ago

I make this inconvenience sometimes, guys. Broad context makes me think in general answer anywwhere. Good job anyway.

AsakusaRinne commented 1 year ago

If a repository is created by me in a organization, and I'm a only a member instead of owner of this organization, it seems not to work. Anyone has an idea about it?