github icon indicating copy to clipboard operation
github copied to clipboard

listPullRequests({ state: 'all' }) does not return all pull requests.

Open sustained opened this issue 6 years ago • 3 comments

Reproduction

const assert = require('assert')
const Github = require('github-api')

const github = new Github()

;(async () => {
  const repo = github.getRepo('vuejs', 'rfcs')

  const all = (await repo.listPullRequests({ state: 'all' })).data.length
  const open = (await repo.listPullRequests({ state: 'open' })).data.length
  const closed = (await repo.listPullRequests({ state: 'closed' })).data.length

  assert.equal(all, open + closed)
})()

See

https://github.com/vuejs/rfcs/pulls

sustained avatar Oct 07 '19 22:10 sustained

Ah. It's relating to all these pagination issues.

Workaround

  const all = await repo._requestAllPages(
    `/repos/${repo.__fullname}/pulls?state=all`,
  )

sustained avatar Oct 07 '19 22:10 sustained

Is this related to pagination? This just seems like an options-passing issue.

j-rewerts avatar Oct 08 '19 13:10 j-rewerts

I don't know.

But I found the _requestAllPages workaround in another issue relating to pagination.

So presumed it was that.

sustained avatar Oct 08 '19 15:10 sustained