Skip to content

Instantly share code, notes, and snippets.

@tylerlittlefield
Created November 21, 2018 17:37
Show Gist options
  • Save tylerlittlefield/1e7ac23dabaa5ae02f1f47966c96b965 to your computer and use it in GitHub Desktop.
Save tylerlittlefield/1e7ac23dabaa5ae02f1f47966c96b965 to your computer and use it in GitHub Desktop.
Gather and count all your merged pull requests
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