Financial-Times / tako

🐙 A GitHub App that provides an API listing the repositories it is installed on.
MIT License
4 stars 0 forks source link

Decommission this repo and use GitHub GraphQL API #197

Open andygout opened 4 years ago

andygout commented 4 years ago

Using GitHub Developer Guide: GraphQL API Explorer, we can make the same queries as those demonstrated in the README:

GET /tako/repositories

Get a list of all the repositories.

{
  "repositories": [
    {
      "name": "foo-bar",
      "owner": "acme",
      "topics": ["example"]
    }
  ]
}

This can be replaced with:

{
  search(type: REPOSITORY, query: "org:Financial-Times topic:customer-products", first: 50) {
    repositoryCount
    repos: edges {
      repo: node {
        ... on Repository {
          name
          repositoryTopics(first: 10) {
            nodes {
              topic {
                name
              }
            }
          }
        }
      }
    }
  }
}

which returns:

{
  "data": {
    "search": {
      "repositoryCount": 279,
      "repos": [
        {
          "repo": {
            "name": "n-express-monitor",
            "repositoryTopics": {
              "nodes": [
                {
                  "topic": {
                    "name": "customer-products"
                  }
                },
                {
                  "topic": {
                    "name": "component"
                  }
                }
              ]
            }
          }
        },
        {
          "repo": {
            "name": "n-makefile",
            "repositoryTopics": {
              "nodes": [
                {
                  "topic": {
                    "name": "customer-products"
                  }
                }
              ]
            }
          }
        },
        …

GET /tako/repositories/?topic=serverless

Get a list of repositories, filtered by a [topic](Get a list of repositories, filtered by a topic.).

{
  "repositories": [
    {
      "name": "foo-bar",
      "owner": "acme",
      "topics": ["example"]
    }
  ]
}

This can be replaced with:

{
  search(type: REPOSITORY, query: "org:Financial-Times topic:customer-products topic:serverless", first: 50) {
    repositoryCount
    repos: edges {
      repo: node {
        ... on Repository {
          name
          repositoryTopics(first: 10) {
            nodes {
              topic {
                name
              }
            }
          }
        }
      }
    }
  }
}

which returns:

{
  "data": {
    "search": {
      "repositoryCount": 26,
      "repos": [
        {
          "repo": {
            "name": "next-myft-email-reporting",
            "repositoryTopics": {
              "nodes": [
                {
                  "topic": {
                    "name": "customer-products"
                  }
                },
                {
                  "topic": {
                    "name": "myft"
                  }
                },
                {
                  "topic": {
                    "name": "serverless"
                  }
                }
              ]
            }
          }
        },
        {
          "repo": {
            "name": "app-push-notifications",
            "repositoryTopics": {
              "nodes": [
                {
                  "topic": {
                    "name": "customer-products"
                  }
                },
                {
                  "topic": {
                    "name": "serverless"
                  }
                },
                {
                  "topic": {
                    "name": "team-apps"
                  }
                },
                {
                  "topic": {
                    "name": "lambda"
                  }
                }
              ]
            }
          }
        },
        …

However…

{
  search(type: REPOSITORY, query: "org:Financial-Times", first: 50) {
    repositoryCount
    repos: edges {
      repo: node {
        ... on Repository {
          name
          repositoryTopics(first: 10) {
            nodes {
              topic {
                name
              }
            }
          }
        }
      }
    }
  }
}

repositoryCount: 2326

and then using a different format of query…

{
  organization(login: "Financial-Times") {
    repositories(first: 100) {
      totalCount
      nodes {
        name
        repositoryTopics(first: 10) {
          nodes {
            topic {
              name
            }
          }
        }
      }
    }
  }

repositoryCount: 2394

Where did 68 missing repos go?

GitHub UI states 2.4k repositories (so the exact figure upon which that was presumably rounded up is unclear):

Screenshot 2020-06-05 at 13 07 30

TODO:

andygout commented 4 years ago

Having spoken to @sjparkinson, we can now also rely on Biz Ops for this information.