Skip to content

Commit e1083b5

Browse files
author
Eric Sorenson
committed
Added section with graphql examples
1 parent aa06c15 commit e1083b5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/open-source-health-metrics.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ You can retrieve information about the [community standards documents](https://d
4343

4444
The Repository object in the GraphQL API is the primary location for metrics which relate to project health. These metrics are available in the `Repository` object, and while there are lots of interesting fields available, we've recently coalesced the most useful ones under the `metrics` field. Check the [API docs](https://docs.github.com/en/graphql/reference/objects#repository) for the full list.
4545

46+
> **Note**
47+
> As of October 2023, the following metrics are in public beta, behind a feature flag. In order to access them, you will need to add a special header to your requests: `GraphQL-Features: ospo_metrics_api`
48+
4649
- **LastContributionDate** - The most recent date there was _any of_ the following activity: a commit to a repository’s default branch, opening an issue or discussion, answering a discussion, proposing a pull request, or submitting a pull request review. This is a good single-number metric to find projects that may be unmaintained or in need of archiving.
4750
- **CommitCount** - A monotonically increasing count of the total number of commits pushed to the default branch of the repository. Tracking the change in this over time will give a sense of the overall activity in the repository.
4851
- **IssueCommentCount** - Similar to CommitCount, this is a monotonically increasing count of the total number of comments on issues in the repository.
52+
53+
### More useful metrics
54+
55+
In addition to the new metrics, there's a lot of useful information tucked away in the existing GraphQL API. Many tools, like the cauldron.io example above, make use of these under the hood, and you might find them helpful in your own dashboards.
56+
57+
- `repository(owner:"monalisa",name:"octocat") { issues { totalCount } }` - returns the number of total issues in the repository
58+
- `repository(owner:"monalisa",name:"octocat") { forkcount }` - the total number of forks of this repository in the fork network (i.e. including forks of forks)
59+
60+
More complex GraphQL queries are possible as well. For example, this query:
61+
62+
```graphql
63+
repository(owner:"voxpupuli",name:"puppetboard") {
64+
pullRequests(states:OPEN) { totalCount }
65+
}
66+
```
67+
68+
Returns the number of open pull requests. Other possible states are `CLOSED` and `MERGED`. Tracking these over time is a key indicator of activity in the repository.

0 commit comments

Comments
 (0)