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

Jump to GraphQL to save some requests? #2

Open
j0k3r opened this issue Feb 15, 2017 · 1 comment
Open

Jump to GraphQL to save some requests? #2

j0k3r opened this issue Feb 15, 2017 · 1 comment

Comments

@j0k3r
Copy link
Owner

j0k3r commented Feb 15, 2017

Request to retrieve all information from tag & release for a given repository.

This one only use releases:

{
  repository(owner: "j0k3r", name: "graby") {
    tags: refs(refPrefix: "refs/tags/", first: 5, direction: DESC) {
      edges {
        tag: node {
          name
          target {
            ... on Tag {
              sha: oid
              message
              tagger {
                name
                date
              }
            }
          }
        }
      }
    }
    releases(last: 5) {
      nodes {
        id
        name
        description
        publishedAt
        tag {
          name
        }
      }
    }
  }
}

This one only use tags:

{
  repository(owner: "rails", name: "rails") {
    tags: refs(refPrefix: "refs/tags/", first: 5, direction: DESC) {
      edges {
        tag: node {
          name
          target {
            ... on Commit {
              message
              author {
                name
                date
              }
            }
            ... on Tag {
              message
              tagger {
                name
                date
              }
            }
          }
        }
      }
    }
    releases(last: 5) {
      nodes {
        id
        name
        description
        publishedAt
        tag {
          name
        }
      }
    }
  }
}

Request to retrieve starred repositories & all information

First page:

{
  user(login: "j0k3r") {
    starredRepositories(first: 50, orderBy: {field: STARRED_AT, direction: ASC}) {
      pageInfo {
        hasNextPage
        hasPreviousPage
        endCursor
      }
      edges {
        node {
          id
          name
          description
          owner {
            login
            avatarURL
          }
        }
      }
    }
  }
}

The second one (using the endCursor as after parameter and until hasNextPage is false):

{
  user(login: "j0k3r") {
    starredRepositories(first: 50, orderBy: {field: STARRED_AT, direction: ASC}, after: "Y3Vyc29yOjIwMTItMDEtMDRUMTE6MjA6NDgrMDE6MDA=") {
      pageInfo {
        hasNextPage
        hasPreviousPage
        endCursor
      }
      edges {
        node {
          id
          name
          description
          owner {
            login
            avatarURL
          }
        }
      }
    }
  }
}
@j0k3r
Copy link
Owner Author

j0k3r commented Feb 16, 2017

Rate limit on GraphQL is limited to 200 calls per hour 😞

j0k3r added a commit that referenced this issue Mar 29, 2017
Like it was done for the version sync, check that rate limit is ok.
Since the worker will handle XX messages before quiting, the given Github client might have already reached its limit when the message will be processed and then result in that error:

[2017-03-29 11:45:02] app.ERROR: [Ack] An exception occurred. Message #2 has been nack'ed. {"swarrot_processor":"ack","exception":"[object] (Github\\Exception\\ApiLimitExceedException(code: 0): You have reached GitHub hourly limit! Actual limit is: 5000 at /www/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php:37)"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant