Skip to content

Highlight issues and PRs from org members #438

Closed

Description

@markspolakovs

Context: for example, in the React team, much of the work happens via PRs, even by the core team. However, these core team PRs are lost in the long, long list of contributions.

Proposal: highlight PRs that are from members of the repo owning org, Facebook in the example of React.

Activity

  1. fregante commented on May 26, 2017

    @fregante
    Member

    I think we'd need an API key for that. This works, but it needs pagination for orgs with 101+ members:

    fetch('https://api.github.com/orgs/facebook/members?per_page=100')
    .then(r => r.json()).then(members => {
        $('.opened-by a').each((i, contributor) => {
            if(members.some(m => m.login === contributor.textContent)) {
                contributor.closest('.Box-row').style.background = '#eee';
            }
        });
    });

    Once v4 goes public we can get a much lighter response (but still paginated):

    query {
      organization(login:"facebook") {
        members(first: 100) {
          edges {
            node {
              login
            }
          }
        }
      }
    }

    graphql

  2. sindresorhus commented on May 26, 2017

    @sindresorhus
    Member

    I think we should wait for the GraphQL API. It will make this much simpler to implement.

  3. fregante commented on May 26, 2017

    @fregante
    Member

    It doesn't look like GraphQL simplifies things in this case, from what I understand the only advantage is getting only what's needed as opposed to a big JSON.

    I hoped you could query the visible user names directly but I don't think that's possible.

  4. changed the title [-]Feature request: Highlight issues and PRs from org members[/-] [+]Highlight issues and PRs from org members[/+] on Oct 18, 2017
  5. fregante commented on Jan 16, 2018

    @fregante
    Member

    This is actually sort of possible in a single GraphQL query:

    query {
      sindresorhus: user(login:"sindresorhus") {
        organizations(first: 100) {
          edges {
            node {
              login
            }
          }
        }
      }
      bfredit: user(login:"bfred-it") {
        organizations(first: 100) {
          edges {
            node {
              login
            }
          }
        }
      }
      etc...
    }

    This lets you query multiple specific users at once for their organizations.

    It still is paginated but I doubt that there are many users that joined more than 100 orgs.

    However: I don't know how you can tell if the current repo is part of an organization, I see no clues in the HTML.

  6. dertieran commented on Sep 4, 2018

    @dertieran
    Contributor

    Just stumbled upon this and if I find the time I will take another look at it, but I see two ways to solve this.

    1. Get all members of an organisation
    This would be the best way if the members could be reused (maybe in the Author filter) and/or saved for that repository/organisation context so we only need to get them once.
    A query could look like this:

    query ($org: String!, $cursor: String) {
      organization(login: $org) {
        login
        members(first: 100, after: $cursor) {
          pageInfo{
            hasNextPage
            endCursor
          }
          nodes {
            login
          }
        }
      }
    }

    This would return a list of members and the page information

    {
      "data": {
        "organization": {
          "login": "bfred-it-obsolete",
          "members": {
            "pageInfo": {
              "hasNextPage": false,
              "endCursor": "Y3Vyc29yOnYyOpHOABVlgQ=="
            },
            "nodes": [
              {
                "login": "bfred-it"
              }
            ]
          }
        }
      }
    }

    If the passed $org isn't an organization the response would be an error/empty.

    {
      "data": {
        "organization": null
      },
      "errors": [
        {
          "message": "Could not resolve to an Organization with the login of 'bfred-it'.",
          "type": "NOT_FOUND",
          "path": [
            "organization"
          ],
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ]
        }
      ]
    }

    2. Test the organization connection for each user
    This would mean that we have a list of users we want to test.
    Instead of the suggested query of @bfred-it it would also be possible to test for that one organization.

    query ($org: String!) {
      sindresorhus: user(login: "sindresorhus") {
        organization(login: $org) {
          login
        }
      }
      bfredit: user(login: "bfred-it") {
        organization(login: $org) {
          login
        }
      }
    }

    This would return the organization or null if the user isn't a member

    {
      "data": {
        "sindresorhus": {
          "organization": null
        },
        "bfredit": {
          "organization": {
            "login": "bfred-it-obsolete"
          }
        }
      }
    }

    Two problems I can see here are that

    1. There is no indication if the $org is actually an organization
    2. The query can't be build that easily and could lead to problems, e.g. there is a limit to how many users could be request at once (something around 50 when I tested it)
  7. fregante commented on Sep 5, 2018

    @fregante
    Member
    1. There is no indication if the $org is actually an organization

    This might need a separate request for each user, perhaps cached forever.

    1. The query can't be build that easily and could lead to problems, e.g. there is a limit to how many users could be request at once (something around 50 when I tested it)

    The PR list only shows 20 PRs at a time, so that's not much of an issue. I built this type of query for my other extension, perhaps you can just copy-paste most of it: https://github.com/bfred-it/github-issue-link-status/blob/a079c3db069e16374713708b521254cecc1329c1/source/content.js#L35-L60

  8. fregante commented on Nov 15, 2018

    @fregante
    Member

    If anyone wants to pick this up:

    .rgh-collaborator {
        border: 1px solid #c0d3eb;
        border-radius: 3px;
        padding: 2px 5px;
    }
    {
      repository(owner: "sindresorhus", name: "refined-github") {
        collaborators(first: 100) {
          nodes {
            login
          }
        }
      }
    }
    {
      "data": {
        "repository": {
          "collaborators": {
            "nodes": [
              {
                "login": "sindresorhus"
              },
              {
                "login": "hkdobrev"
              },
              {
                "login": "SpaceK33z"
              },
              {
                "login": "kevva"
              },
              {
                "login": "paulmolluzzo"
              },
              {
                "login": "busches"
              },
              {
                "login": "bfred-it"
              },
              {
                "login": "SamVerschueren"
              },
              {
                "login": "jgierer12"
              },
              {
                "login": "DrewML"
              }
            ]
          }
        }
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions