anuraghazra / github-readme-stats

:zap: Dynamically generated stats for your github readmes
https://github-readme-stats.vercel.app
MIT License
68.22k stars 22.34k 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)
anuraghazra commented 2 years ago

Hi @developStorm I'll consider your PR this weekend. I'll consider it based on the reactions on your comments and majority of them.

rickstaa commented 2 years ago

@anuraghazra I added the #1450 to allow people to make their star count more representative when #1122 has been merged. I, for example, am a contributor to some popular repositories for which, based on the number of commits, I don't feel like I deserve the stars. Below is just an example since I could have removed the ORGANIZATION_MEMBER tag but adding the exclude_repo option to the stats card would allow me to exclude specific repositories.

We can of course also look for a middle ground and allow the ORGANIZATION_MEMBER option for the language card but filter it out in the stats card.

My stats with reviewdog

Rick's Github stats

My stats without reviewdog

Rick's Github stats

rickstaa commented 2 years ago

@developStorm Don't users also receive the stars and languages results when they add their user accounts as collaborators of the repositories in the organizations they created (see https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation)? In that case, I have to agree with @anuraghazra https://github.com/anuraghazra/github-readme-stats/issues/1#issuecomment-864451245 that we should filter out the ORGANIZATION_MEMBER value for both the language and stats card.

Verify

Let's quickly test the assumption above by creating a new organization (i.e. https://github.com/orgs/github-readme-stats-issue-1-test), creating (i.e. a new repository github-readme-stats-issue-1-test, adding myself as a member and giving it 2 stars. I received the 2 stars from the organization repository, although I did not commit to it. You can see this behaviour in action the GraphqExplorer by using the following syntax:

query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation]) {
  user(login: $login) {
    repositories(first: 100, ownerAffiliations: $ownerAffiliations, orderBy: {direction: DESC, field: STARGAZERS}) {
      totalCount
      nodes {
        name
        stargazers {
          totalCount
        }
      }
    }
  }
}

while using variables:

{"login": "rickstaa", "ownerAffiliations": ["COLLABORATOR"]}
guillaumearnx commented 2 years ago

Hello,

I've deployed my own Vercel Instance but I'm not able to fetch languages in organizations like with https://github-readme-stats-one-bice.vercel.app instance. I suppose that it's a fork with more features but I'm not able to find the source code. Please can someone help me ?

Thank's

rickstaa commented 2 years ago

@guillaumearnx To use the organization feature you have to merge #1122 into one of your branches. If you set up your own Vercel instance according to the documentation you should then be able to use the organization feature using the link provided by vercel.

Feel free to temporary use my Vercel instance until this feature request has been merged. The link for this instance can be found in my personal README.

guillaumearnx commented 2 years ago

Thank's @rickstaa. If i want to wetch my private repos, do i need to run my own instance with your fork ? Because I can't see my private repos with your instance

rickstaa commented 2 years ago

@guillaumearnx In that case, you need to create your own instance since a Personal Access Token needs to be present in the instance. I am happy to help if you run into problems. The following steps should get it working for you:

  1. Fork the https://github.com/anuraghazra/github-readme-stats repository.
  2. Follow the Vercel instance documentation to set up your own Vercel instance.
  3. Clone your fork to your PC git clone <FORK_SSH_URL>.
  4. Create a new branch git checkout -b org-stats.
  5. Add @developStorm remote to your remotes git remote add develop git@github.com:developStorm/github-readme-stats.git.
  6. Fetch the remote git fetch develop
  7. Merge @developStorm changes into your branch git merge develop/master.
  8. Push these changes to your remote git push.
  9. On Vercel you will see that an instance has been deployed for the org-stats branch.
  10. You can use the link that is shown for that deployment to create your cards.
guillaumearnx commented 2 years ago

thank's a lot

sumchowd commented 2 years ago

While this issue is still open, I found another repository that provides this feature in the short term. Github Trends looks at individual commits as opposed to repository stats, so it counts contributions to open-source repos.

https://www.github.com/avgupta456/github-trends

Enaium commented 2 years ago

While this issue is still open, I found another repository that provides this feature in the short term. Github Trends looks at individual commits as opposed to repository stats, so it counts contributions to open-source repos.

https://www.github.com/avgupta456/github-trends

but this still can't organization stats

KendallDoesCoding commented 2 years ago

Is this coming soon?

FLAK-ZOSO commented 2 years ago

@KendallDoesCoding, I really hope that. I've never committed anything in this repository, so I don't even know how much complicated it would be, but I'm sure it would be useful.

KendallDoesCoding commented 2 years ago

@KendallDoesCoding, I really hope that. I've never committed anything in this repository, so I don't even know how much complicated it would be, but I'm sure it would be useful.

Yeah, I want to use it for my organization personally.

rickstaa commented 2 years ago

@developStorm Don't users also receive the stars and languages results when they add their user accounts as collaborators of the repositories in the organizations they created (see https://docs.github.com/en/graphql/reference/enums#repositoryaffiliation)? In that case, I have to agree with @anuraghazra #1 (comment) that we should filter out the ORGANIZATION_MEMBER value for both the language and stats card.

Verify

Let's quickly test the assumption above by creating a new organization (i.e. https://github.com/orgs/github-readme-stats-issue-1-test), creating (i.e. a new repository github-readme-stats-issue-1-test, adding myself as a member and giving it 2 stars. I received the 2 stars from the organization repository, although I did not commit to it. You can see this behaviour in action the GraphqExplorer by using the following syntax:

query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation]) {
  user(login: $login) {
    repositories(first: 100, ownerAffiliations: $ownerAffiliations, orderBy: {direction: DESC, field: STARGAZERS}) {
      totalCount
      nodes {
        name
        stargazers {
          totalCount
        }
      }
    }
  }
}

while using variables:

{"login": "rickstaa", "ownerAffiliations": ["COLLABORATOR"]}

@developStorm Friendly, ping to see if you have seen my previous comment. ๐Ÿ˜„

developStorm commented 2 years ago

@rickstaa Hi Rick, I appreciate your efforts on this issue! I did see your comment earlier, but I don't see a problem with giving users this freedom of choice. They are the ones who are ultimately responsible for their own user homepage. Since we don't have it as a default, I think we should be okay.

But then again, after I joined multiple organizations myself, this did get a bit cumbersome to manage. Plus the owners of this stat card project have been very inactive about this long-standing issue (it's been over 150 days since they last promised to review #1122 "this weekend" ๐Ÿ˜…), I'm a little disheartened about this now. Personally, I would probably choose to migrate to some other GitHub Action-based project to get a greater degree of customizability and longer computation times. If runtime is not an issue, it is well possible to calculate user contributions in a more accurate way (e.g. cloning all repositories and scanning language distribution in commits actual made by the user).

joaovian06 commented 2 years ago

any update in this issue?

rickstaa commented 2 years ago

@developStorm Thanks a lot for your answer. The PR you created is valuable and should be merged into the repository (it is the most requested feature). As of lately, I have been added as a collaborator to help @anuraghazra deal with the popularity of this repository. I am happy to review your PR and merge it. However, since it is a significant change, I first want to agree on including the ORGANIZATION_MEMBER option. Let's, therefore, wait for @anuraghazra to state his thoughts about this.

rickstaa commented 2 years ago

@joaovian06 Hope my comment above helps!

A small note for everyone. Altough I understand the importance of this feature, please be aware that @anuraghazra maintains this project in his free time. ๐Ÿ…๐Ÿš€ Bumping this issue will therefore not speed up the process but will put stress on the collaborators of this repository. If you want this feature implemented, it is best to show your support using the like buttons under the first comment. If you have questions or suggestions about implementing this feature, feel free to comment on the pull request: https://github.com/anuraghazra/github-readme-stats/pull/1122.

rickstaa commented 2 years ago

I would probably choose to migrate to some other GitHub Action-based project to get a greater degree of customizability and longer computation times. If runtime is not an issue, it is well possible to calculate user contributions more accurately (e.g. cloning all repositories and scanning language distribution in commits actual made by the user).

@developStorm, I see. I, however, am not sure how this method is possible in a cost-effective way. I think using the Github graphql API is just as accurate.

The main concern some people have is with how the stars are calculated. I agree that it would be better to include all the contributions to public, private and organization repositories. For organizations, you could then divide the code changes a person made by the total code in the repository and multiply the stars by that number. This, however, favours people that write lengthy (bad) code. ๐Ÿ˜… It also neglects all the other things people can do to contribute to an open-source project, like code reviews and answering issues and discussions.

I, therefore, think the version you implemented in #1122, with the ORGANIZATION_MEMBER option filtered out, serves as an excellent middle ground. If people want to create a false star count, we cannot stop them anyway. ๐Ÿฅฒ

developStorm commented 2 years ago

This, however, favours people that write lengthy (bad) code. ๐Ÿ˜… It also neglects all the other things people can do to contribute to an open-source project, like code reviews and answering issues and discussions.

@rickstaa This is true. If you want to achieve absolutely fair distribution, we need to provide a platform for all organization administrators to register and submit the actual workload of their members. Overall, automating the assessment of workload sounds impossible to me. So since you can't do it accurately anyway, you might as well let the users do the job themselves. If a person's home page shows 100,000 stars stats card but no pinned repo shows their contribution to those stars, other people are not fools.

nyxb commented 2 years ago

5. git add remote develop git@github.com:developStorm/github-readme-stats.git

@rickstaa fatal: pathspec 'remote' did not match any files <--@phpstorm

rickstaa commented 2 years ago
  1. git add remote develop git@github.com:developStorm/github-readme-stats.git

@rickstaa fatal: pathspec 'remote' did not match any files <--@phpstorm

Makes sense. It should be git remote add develop git@github.com:developStorm/github-readme-stats.git small typo.

nyxb commented 2 years ago
  1. git add remote develop git@github.com:developStorm/github-readme-stats.git

@rickstaa fatal: pathspec 'remote' did not match any files <--@phpstorm

Makes sense. It should be git remote add develop git@github.com:developStorm/github-readme-stats.git small typo.

I made it easier for myself and foked yours. since I adjusted something and started my vercel instance. ๐Ÿ˜

maxlingenfelter commented 2 years ago

Any updates on when this will be supported publicly?

rickstaa commented 2 years ago

@PekayTab Thanks for your question. As explained in #1122 there are several changes that have to be applied before #1122 can be merged.

@developStorm Thanks for your detailed response. I have no problem merging this pull request. I have used it for months on my own GitHub readme. ๐Ÿš€ That's why I have been trying to merge it into the main branch. I also don't care about cheating since, in the end, it is impossible to prevent๐Ÿ˜‹. I only pointed out that:

  1. I think we should filter out the ORGANIZATION_MEMBER group. Having this group enabled will also add stars of repositories in my organizations to which I never committed. I think the COLLABORATOR will group will already resolve #1.
  2. It might be unwise to support ownerAffiliations for the language card due to the current implementation of the GraphQL API. The current API and the ownerAffiliations option enabled all languages in all repositories a user is a member of will be counted. This might not be a good indication of language fluency. However, if point 1 is fixed, I don't think it will be worse than the incorrect results we currently have for the language card. I think the exclude_repo option and #1732 will provide users with more than enough ways to fix their language card if they feel it is incorrect.

As a result, because this feature has been widely requested from the community since 9 Jul 2020, I'm good with merging this PR if the following things are fixed:

Nevertheless, since I'm not the owner of this project, I will leave this decision to @anuraghazra.

Originally posted by @rickstaa in https://github.com/anuraghazra/github-readme-stats/issues/1122#issuecomment-1152237425

I'm however waiting for feedback of @anuraghazra before I applying these changes.

mendax1234 commented 2 years ago

When will stats for an organization be supported? If so, how to use it?

rickstaa commented 2 years ago

Hey @mendax1234, thanks for your interest in this feature. Although it is not officially supported yet, I already use it on my fork (see my readme). The steps for using this feature are found here.

Unfortunately, I can not give an ETA for this feature (see https://github.com/anuraghazra/github-readme-stats/issues/1#issuecomment-1180126339 for more information).

RuiGuilherme commented 2 years ago

@rickstaa I just tested your deployment on Vercel with support for organizations, I believe that the "Top Language" is not working correctly. The main languages of the repositories are in Java and that's more than 500 commits and I didn't have any changes in the "Top Language".

Are there any limitations at the moment to check the languages of private organizations?

rickstaa commented 2 years ago

@RuiGuilherme If you followed these steps for deploying your own private instance and added a PAT that has access to the repositories of these private organizations, it should work. The permissions are the same as in the GraphQL Explorer when you're logged in (see https://github.com/anuraghazra/github-readme-stats/discussions/1770#language-card-is-incorrect).

RuiGuilherme commented 2 years ago

@RuiGuilherme If you followed these steps for deploying your own private instance and added a PAT that has access to the repositories of these private organizations, it should work. The permissions are the same as in the GraphQL Explorer when you're logged in (see #1770 (comment)).

It worked perfectly, thank you very much for the quick response.

VianaSamuel commented 1 year ago

@guillaumearnx In that case, you need to create your own instance since a Personal Access Token needs to be present in the instance. I am happy to help if you run into problems. The following steps should get it working for you:

  1. Fork the https://github.com/anuraghazra/github-readme-stats repository.
  2. Follow the Vercel instance documentation to set up your own Vercel instance.
  3. Clone your fork to your PC git clone <FORK_SSH_URL>.
  4. Create a new branch git checkout -b org-stats.
  5. Add @developStorm remote to your remotes git remote add develop git@github.com:developStorm/github-readme-stats.git.
  6. Fetch the remote git fetch develop
  7. Merge @developStorm changes into your branch git merge develop/master.
  8. Push these changes to your remote git push.
  9. On Vercel you will see that an instance has been deployed for the org-stats branch.
  10. You can use the link that is shown for that deployment to create your cards.

So, I'm kinda a newbie on git and I was trying to follow your tutorial. Everything went fine until the 8th step (git push).

That's what I got when I tried to do that in the terminal:

fatal: The current branch org-stats has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin org-stats

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

So I tried the git push --set-upstream origin org-stats and everything (apparently) went fine, the Vercel deployed again, but my stats cards was still the same.

If possible, could you give me some help? And apologies in advance for the bothering, I'm completely layman with git.

rickstaa commented 1 year ago

@guillaumearnx In that case, you need to create your own instance since a Personal Access Token needs to be present in the instance. I am happy to help if you run into problems. The following steps should get it working for you:

  1. Fork the https://github.com/anuraghazra/github-readme-stats repository.
  2. Follow the Vercel instance documentation to set up your own Vercel instance.
  3. Clone your fork to your PC git clone <FORK_SSH_URL>.
  4. Create a new branch git checkout -b org-stats.
  5. Add @developStorm remote to your remotes git remote add develop git@github.com:developStorm/github-readme-stats.git.
  6. Fetch the remote git fetch develop
  7. Merge @developStorm changes into your branch git merge develop/master.
  8. Push these changes to your remote git push.
  9. On Vercel you will see that an instance has been deployed for the org-stats branch.
  10. You can use the link that is shown for that deployment to create your cards.

So, I'm kinda a newbie on git and I was trying to follow your tutorial. Everything went fine until the 8th step (git push).

That's what I got when I tried to do that in the terminal:

fatal: The current branch org-stats has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin org-stats

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

So I tried the git push --set-upstream origin org-stats and everything (apparently) went fine, the Vercel deployed again, but my stats cards was still the same.

If possible, could you give me some help? And apologies in advance for the bothering, I'm completely layman with git.

For now, you should add the &role=OWNER,COLLABORATOR parameter to your card for the organization results to show up. This is not yet documented since this feature has not yet been merged into the master branch. I will probably change it to &include_orgs when we release it. You can checkout my README for an example.

brunolnetto commented 1 year ago

The feature seems mature at this level. Who and when will we merge it on main repository?

brunolnetto commented 1 year ago

I followed the instructions available on the post, as you can see by commits and action approval on post. I had to additionally:

  1. fix conflicts with master branch;
  2. Run command npm run install && npm run prepare && npm run run prettier && npm run run prettier:check to assure the local environment was similar to this library's author.

After auto-deploy my own vercel app and substitution on original repository, it rendered the image below. What did I wrong? :-(

image

ningding97 commented 1 year ago

@guillaumearnx In that case, you need to create your own instance since a Personal Access Token needs to be present in the instance. I am happy to help if you run into problems. The following steps should get it working for you:

  1. Fork the https://github.com/anuraghazra/github-readme-stats repository.
  2. Follow the Vercel instance documentation to set up your own Vercel instance.
  3. Clone your fork to your PC git clone <FORK_SSH_URL>.
  4. Create a new branch git checkout -b org-stats.
  5. Add @developStorm remote to your remotes git remote add develop git@github.com:developStorm/github-readme-stats.git.
  6. Fetch the remote git fetch develop
  7. Merge @developStorm changes into your branch git merge develop/master.
  8. Push these changes to your remote git push.
  9. On Vercel you will see that an instance has been deployed for the org-stats branch.
  10. You can use the link that is shown for that deployment to create your cards.

Hi, like many other developers, I maintain open-source projects in an organization but not a personal account. After strictly following the instructions, I find that the number of total stars is still not changed (while the number of total commits increases). I'm not an expert on js, so could you please summarize the current criterion here? For example, if I am a member of an organization, and I have created, admined, and maintained some projects, will the stars of these projects be counted? Thx!

LucBerge commented 1 year ago

Hello, Most of my personnal work has been moved to organizations as well. I'm also really interested about this feature !

brunolnetto commented 1 year ago

@LucBerge I failed to reproduce the same as @rickstaa did. So, I used his vercel deployed app :-P. You can use my README content and replace property username right-hand side by yours.

brunolnetto commented 1 year ago

I think the language count in "Jupyter Notebook" is overrated: look at my profile! This language bar is much bigger than others, which makes me think it counts code rows instead of files. However, since this programming language uses cells to do its stuff, most file rows are rendered and style definitions.

wleoncio commented 1 year ago

IIRC the stats already count lines of code, not files. The issue is that behind the simplest Jupyter Notebook is hundreds, maybe thousands of lines of JSON code. For example, I just started and saved an empty ipynb file. This is what I see when I open that same file on vim:

{
  "cells": [
   {
    "cell_type": "code",
    "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": []
   }
  ],
  "metadata": {
   "language_info": {
    "name": "python"
   },
   "orig_nbformat": 4
  },
  "nbformat": 4,
  "nbformat_minor": 2
}

That's 19 lines of code for a file containing nothing but an empty cell, so it's no wonder having a couple of Jupyter Notebooks would be enough for it to dominate someone's stats. Until that gets fixed to reflect actual human-written code, you might want to configure your stats to ignore the language.

rickstaa commented 1 year ago

@wleoncio Thanks for the detailed explanation. @brunolnetto, you can use the hide parameter (i.e. &hide=jupyter%20notebook) to remove the jupyter notebook results. See https://github.com/anuraghazra/github-readme-stats#hiding-individual-stats for more information.

Ran-Xing commented 1 year ago

+1+1

rickstaa commented 1 year ago

As of today, people can also use the https://github.com/anuraghazra/github-readme-stats/tree/master_orgs branch in their own Vercel deployments to include organization stats.

Warning Please remember that this is an unreleased feature (see #2277), so things can still break. Further, please be aware that because of https://github.com/anuraghazra/github-readme-stats/issues/1852, only the first 100 repositories are used. Including organization, stats might therefore skew your results.

rickstaa commented 1 year ago

You can also already use this feature with the syntax shown below. Please, be aware that since this feature is not yet merged, the exact syntax is changed, so it is better to fork the repository, deploy your own Vercel instance and use the master_orgs branch.

Without org stats

Anurag's GitHub stats

[![Anurag's GitHub stats](https://github-readme-stats-git-masterorgs-github-readme-stats-team.vercel.app/api?username=rickstaa)](https://github.com/anuraghazra/github-readme-stats)

Top Langs

[![Top Langs](https://github-readme-stats-git-masterorgs-github-readme-stats-team.vercel.app/api/top-langs/?username=rickstaa)](https://github.com/anuraghazra/github-readme-stats)

With org stats

Anurag's GitHub stats

[![Anurag's GitHub stats](https://github-readme-stats-git-masterorgs-github-readme-stats-team.vercel.app/api?username=rickstaa&include_orgs=true)](https://github.com/anuraghazra/github-readme-stats)

Top Langs

[![Top Langs](https://github-readme-stats-git-masterorgs-github-readme-stats-team.vercel.app/api/top-langs/?username=rickstaa&include_orgs=true)](https://github.com/anuraghazra/github-readme-stats)
brunolnetto commented 1 year ago

Great! ๐Ÿ˜ฑ

rickstaa commented 1 year ago

Great! scream

No problem. As stated in https://github.com/anuraghazra/github-readme-stats/issues/1#issuecomment-1321887994 I can not give any guarantees that the syntax stays the same since https://github.com/anuraghazra/github-readme-stats/pull/2277 is still under review. It would be best if you used the master_orgs branch of your own Vercel deployment.

Ran-Xing commented 1 year ago

่ฏทๅฐฝๅฟซๅฎ‰ๆŽ’๏ผŒๆˆ‘่ถ…ๅ–œๆฌข๏ผŒ็œŸ็š„็‰›้€ผ

Please arrange it as soon as possible. I like it very much. NIU BI

brunolnetto commented 1 year ago

@rickstaa I copy-pasted your readme. It means, as soon as you do not update your vercel app instance, I am good. However, since it seems you are the most active collaborator to this project, I must somewhen in the future consider to build my own instance.

rickstaa commented 1 year ago

@rickstaa I copy-pasted your readme. It means, as soon as you do not update your vercel app instance, I am good. However, since it seems you are the most active collaborator to this project, I must somewhen in the future consider to build my own instance.

No worries I'm not gonna change the syntax of the master_rstaa branch until https://github.com/anuraghazra/github-readme-stats/pull/2277 is merged. Otherwise, I will let you know. ๐Ÿ‘๐Ÿป

brunolnetto commented 1 year ago

I earned an A++. I am feeling lovely

rickstaa commented 1 year ago

@brunolnetto I think it is best for now that you switch to https://github-readme-stats-git-masterorgs-github-readme-stats-team.vercel.app since I'm not updating the master-rstaa branch anymore and I might remove it in the future. I'm now using my master_rstaa branch.