Skip to content

Instantly share code, notes, and snippets.

@jhollist
Created June 20, 2017 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhollist/2c5a86984a49e9afc29475c093fe5a8c to your computer and use it in GitHub Desktop.
Save jhollist/2c5a86984a49e9afc29475c093fe5a8c to your computer and use it in GitHub Desktop.
library(gh)
library(dplyr)
library(lubridate)
library(purrr)
usepa_members <- unlist(lapply(gh("/orgs/usepa/members", .limit = Inf),
function(x) x$login))
# Get all usepa repos, grab commits for each repo, filter for user and count
usepa_repos <- unlist(lapply(gh("/orgs/usepa/repos", type = "all", .limit = Inf),
function(x) x$name))
usepa_commits <- c(gh(paste0("/repos/usepa/",usepa_repos[1],"/commits"),
.limit = Inf))
n <- 1
for(i in usepa_repos[-1]){
n <- n + 1
#Hack to avoid 409s
if(n != 42){
usepa_commits <- c(usepa_commits, gh(paste0("/repos/usepa/",i,"/commits"),
.limit = Inf))
message(paste0("Added ",i, " (",n, "of", length(usepa_repos), "repos)"))
}
}
user <- vector()
num_commits <- vector()
for(i in usepa_members){
user <- c(user,i)
num_commits <- c(num_commits,sum(unlist(lapply(usepa_commits,
function(x) x$author$login == i))))
}
user_commit_stats <- data.frame(user,num_commits) %>%
arrange(desc(num_commits))
tbl_df(user_commit_stats)
# A tibble: 437 × 2
# user num_commits
# <fctr> <int>
#1 jhollist 1275
#2 michaelbynum 468
#3 transue 453
#4 MarkGrayRESPEC 426
#5 kaklise 402
#6 TongZhai 402
#7 PaulDudaRESPEC 346
#8 cman81 269
#9 dbhart 152
#10 msrocka 145
# ... with 427 more rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment