Created
November 21, 2018 17:37
-
-
Save tylerlittlefield/1e7ac23dabaa5ae02f1f47966c96b965 to your computer and use it in GitHub Desktop.
Gather and count all your merged pull requests
This file contains 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 characters
library(gh) | |
library(tidyverse) | |
library(jsonlite) | |
gh("/search/issues?q=author:tylurp+type:pr+is:merged") %>% | |
toJSON() %>% | |
fromJSON() %>% | |
.$items %>% | |
.$pull_request %>% | |
.$url %>% | |
map_chr(~ str_remove(., ".*repos/")) %>% | |
map_chr(~ str_remove(., "/pulls.*")) %>% | |
as_tibble() %>% | |
count(value, sort = TRUE) %>% | |
set_names("repo", "prs_merged") | |
# Or wrap it into a function | |
merged_prs <- function(user) { | |
endpoint_str <- glue::glue("/search/issues?q=author:{user}+type:pr+is:merged") | |
gh(endpoint_str) %>% | |
toJSON() %>% | |
fromJSON() %>% | |
.$items %>% | |
.$pull_request %>% | |
.$url %>% | |
map_chr(~ str_remove(., ".*repos/")) %>% | |
map_chr(~ str_remove(., "/pulls.*")) %>% | |
as_tibble() %>% | |
count(value, sort = TRUE) %>% | |
set_names("repo", "prs_merged") | |
} | |
merged_prs("tylurp") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment