Last active
January 14, 2025 07:25
-
-
Save mikaelvesavuori/a0b75f0ebc617e20caab42a2b25c66f3 to your computer and use it in GitHub Desktop.
Revisions
-
mikaelvesavuori revised this gist
Nov 22, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,10 +8,10 @@ These are some handy snippets to get common metrics for checking how active a so ## Setup **The API endpoint is [https://api.github.com/graphql](https://api.github.com/graphql)**. Don't forget to [create a Personal Access Token ("classic")](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and set the correct headers before calling the API. | Header | Value | | ---------------- | -------------------------------- | | `Content-Type` | `application/json` | -
mikaelvesavuori revised this gist
Nov 22, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,8 @@ These are some handy snippets to get common metrics for checking how active a so Don't forget to [create a Personal Access Token ("classic")](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and set the correct headers before calling the API. **The API endpoint is [https://api.github.com/graphql](https://api.github.com/graphql)**. | Header | Value | | ---------------- | -------------------------------- | | `Content-Type` | `application/json` | -
mikaelvesavuori revised this gist
Nov 22, 2022 . 1 changed file with 35 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,25 @@ # Get Individual Contributor metrics from GitHub's GraphQL API These are some handy snippets to get common metrics for checking how active a software engineer is. - How many pushes are made by the IC? - How many reviews are made by the IC? - How many comments are made by the IC? ## Setup Don't forget to [create a Personal Access Token ("classic")](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and set the correct headers before calling the API. | Header | Value | | ---------------- | -------------------------------- | | `Content-Type` | `application/json` | | `Accept` | `application/vnd.github.v3+json` | | `Authorization` | `Bearer {PAT}` | ## References - [GitHub GraphQL API](https://docs.github.com/en/graphql) - [Searching issues and pull requests](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) ## How many pushes are made by the IC? @@ -25,7 +44,7 @@ query ($user: String!, $start: DateTime!, $end: DateTime!) { } ``` ### Query variables ```json { @@ -35,6 +54,10 @@ Query variables: } ``` ### JSONPath Plus Use `$.data..totalCount` to get the count for each repository. ## How many reviews are made by the IC? ```gql @@ -60,14 +83,18 @@ query ($query: String!) { } ``` ### Query variables ```json { "query": "created:2022-01-01..2022-12-31 reviewed-by:YOUR_USER" } ``` ### JSONPath Plus Use `$.data.search.nodes.length` to get the count. ## How many comments are made by the IC? ```gql @@ -90,10 +117,14 @@ query ($query: String!) { } ``` ### Query variables ```json { "query": "created:2022-01-01..2022-12-31 commenter:YOUR_USER" } ``` ### JSONPath Plus Use `$.data.search.nodes.length` to get the count. -
mikaelvesavuori revised this gist
Nov 22, 2022 . 1 changed file with 55 additions and 55 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,94 +6,94 @@ Description. ```gql query ($user: String!, $start: DateTime!, $end: DateTime!) { user(login: $user) { contributionsCollection(from: $start, to: $end) { commitContributionsByRepository(maxRepositories: 100) { repository { nameWithOwner } contributions { totalCount } } } } rateLimit { cost remaining } } ``` Query variables: ```json { "user": "YOUR_USER", "start": "2022-01-01T00:00:00Z", "end": "2022-12-31T00:00:00Z" } ``` ## How many reviews are made by the IC? ```gql query ($query: String!) { search(last: 100, query: $query, type: ISSUE) { nodes { ... on PullRequest { number title createdAt mergedAt } } pageInfo { hasNextPage endCursor } } rateLimit { cost remaining } } ``` Query variables: ```json { "query": "created:2022-01-01..2022-12-31 reviewed-by:YOUR_USER" } ``` ## How many comments are made by the IC? ```gql query ($query: String!) { search(last: 100, query: $query, type: ISSUE) { nodes { ... on Comment { createdAt } } pageInfo { hasNextPage endCursor } } rateLimit { cost remaining } } ``` Query variables: ```json { "query": "created:2022-01-01..2022-12-31 commenter:YOUR_USER" } ``` -
mikaelvesavuori renamed this gist
Nov 22, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mikaelvesavuori created this gist
Nov 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,99 @@ # Get Individual Contributor metrics from GitHub's GraphQL API Description. ## How many pushes are made by the IC? ```gql query ($user: String!, $start: DateTime!, $end: DateTime!) { user(login: $user) { contributionsCollection(from: $start, to: $end) { commitContributionsByRepository(maxRepositories: 100) { repository { nameWithOwner } contributions { totalCount } } } } rateLimit { cost remaining } } ``` Query variables: ```json { "user": "YOUR_USER", "start": "2022-01-01T00:00:00Z", "end": "2022-12-31T00:00:00Z" } ``` ## How many reviews are made by the IC? ```gql query ($query: String!) { search(last: 100, query: $query, type: ISSUE) { nodes { ... on PullRequest { number title createdAt mergedAt } } pageInfo { hasNextPage endCursor } } rateLimit { cost remaining } } ``` Query variables: ```json { "query": "created:2022-01-01..2022-12-31 reviewed-by:YOUR_USER" } ``` ## How many comments are made by the IC? ```gql query ($query: String!) { search(last: 100, query: $query, type: ISSUE) { nodes { ... on Comment { createdAt } } pageInfo { hasNextPage endCursor } } rateLimit { cost remaining } } ``` Query variables: ```json { "query": "created:2022-01-01..2022-12-31 commenter:YOUR_USER" } ```