Github GraphQL API get count of issues on particular date

Viewed 416

I am using the GitHub Graphql API to pull issues for a repository. Here is how the query looks like:

query { 
  repository(owner:"OWNER", name:"REPOSITORYNAME") { 
    issues(states:OPEN) {
      totalCount
    }
  }
}

the response payload contains the count of open issues for the repository.

{
  "data": {
    "repository": {
      "issues": {
        "totalCount": 375
      }
    }
  }
}

Searched the docs but couldn't find anything relevant, Is there a way we can query the number of open issues that were open at a historical date? say, the totalCount of open issues for the repository on 10-12-2020?

2 Answers

I don't think you can do this with graphql, but you could get the info from the search API with a combination of https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-when-an-issue-or-pull-request-was-created-or-last-updated

and

https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-when-an-issue-or-pull-request-was-closed

It's not ideal since if an issue was closed, reopened and then closed again it may be counted incorrectly, but I'm not sure there's a clean way to do what you want

This isn't answering your question completely, but shows the number of issues in a repository created on or before a particular date:

query MyQuery {
  search(query: "org:isaacs repo:github created:<=2020-10-12", type: ISSUE) {
        issueCount
  }
}

For more things that can be used with search(query), see the search syntax docs.

Related