Github User Profile

Kovid Goyal

  • Number of Repositories : 31
  • Number of followers : 2.2k
  • Number of contributions last year : 2075

Code

Load Libraries

library(gh)
library(tidyverse)
library(readxl)
library(ggplot2)
library(knitr)
library(kableExtra)

API Token

api_key <- "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"

Get user data

endpoint_user = "/users/{USER_NAME}"

user_data <- gh(endpoint_user, USER_NAME="kovidgoyal") 

user_table <- data.frame(login = user_data$login,
                        name = user_data$name, 
                        public_repos = user_data$public_repos, 
                        followers = user_data$followers)

kbl(cbind(user_table)) %>%
  kable_paper() %>%
  scroll_box(width = "100%", height = "100%")
login name public_repos followers
kovidgoyal Kovid Goyal 31 2178

Get user followers data

followers_data <- gh(user_data$followers_url,
                     #.limit = Inf,
                     .token = api_key)

df1 <- followers_data %>% 
  map(unlist) %>% 
  map(t) %>% 
  map(as_tibble) 
df1 = bind_rows(df1)
df1 <- df1 %>% 
  select(c("login","url","repos_url"))

followers_table <- data.frame(login = character(),
                              name = character(),
                              public_repos = character(),
                              followers = character()
                              )

for (x in 1:nrow(df1)) {
  user_data <- gh(endpoint_user, USER_NAME=df1$login[x],
                  .token = api_key
                  )

followers_table[nrow(followers_table) + 1,] = c(if(is.null(user_data$login)) "NULL" else user_data$login,
                                                if(is.null(user_data$name)) "NULL" else user_data$name,
                                                if(is.null(user_data$public_repos)) "NULL" else user_data$public_repos,
                                                if(is.null(user_data$followers)) "NULL" else user_data$followers)
}

kbl(cbind(followers_table)) %>%
  kable_paper() %>%
  scroll_box(width = "100%", height = "200px")
login name public_repos followers
croaky Dan Croak 37 373
entombedvirus Rohith Ravi 26 27
acangiano Antonio Cangiano 5 414
alakra Angelo Lakra 19 51
blissdev Jordan Arentsen 25 54
mrluanma Zhao Xiaohong 12 320
zdk Di Warachet S. 39 68
evanfarrar Evan Farrar 79 70
blueyed Daniel Hahler 591 392
diclophis Jon Bardin 109 104
rubiojr Sergio Rubio 312 319
galvez Jonas Galvez 62 427
vitorpy Vitor Py 22 38
rauchg Guillermo Rauch 123 11015
p3k Tobi Schäfer 33 50
beshrkayali Beshr Kayali 65 89
fishman Reza Jelveh 250 55
hjdivad David J. Hamilton 124 81
debajit Debajit Adhikary 24 7
lowply Sho Mizutani 53 46
matthewbauer Matthew Bauer 421 212
kzys Kazuyoshi Kato 96 206
joellobo Joel Lobo 181 34
hiway Harshad Sharma 214 109
chetan Chetan Sarva 235 76
jace Kiran Jonnalagadda 38 402
aareet Aareet Mahadevan 84 42
dlo Dan Loewenherz 112 172
andrus Andrus Adamchik 32 65
swaroopch Swaroop CH 28 666

Get user repo data

endpoint_repos = "/users/{USER_NAME}/repos"
endpoint_closed_issue_count = "/search/issues?q=repo:{USER_NAME}/{REPO_NAME}+type:issue+state:closed"

repo_table <- data.frame(name = character(),
                  size = character(),
                  forks_count = character(),
                  open_issues_count = character(),
                  closed_issue_count=character())

repo_data <- gh(endpoint_repos, USER_NAME="kovidgoyal", 
                #.limit = Inf, 
                .token = api_key )

for (x in 1:length(repo_data)) {
  closed_issue = gh(endpoint_closed_issue_count,
                    USER_NAME="kovidgoyal", 
                    REPO_NAME=repo_data[[x]]$name, 
                    .token = api_key)
  
  repo_table[nrow(repo_table) + 1,] = c(repo_data[[x]]$name,
                                        repo_data[[x]]$size,
                                        repo_data[[x]]$forks_count,
                                        repo_data[[x]]$open_issues_count,
                                        closed_issue$total_count)

}

kbl(cbind(repo_table)) %>%
  kable_paper() %>%
  scroll_box(width = "100%", height = "200px")
name size forks_count open_issues_count closed_issue_count
ale 17656 0 0 0
build-calibre 627 12 1 16
bypy 1478 15 0 3
calibre 280534 1667 2 0
calibre-translations 948501 3 1 0
cpython 212449 9 0 0
cpython-source-deps 46960 0 0 0
dukpy 1232 4 1 0
html5-parser 1029 31 0 20
i3 10063 0 0 0
iv 56 2 0 1
kitty 36764 685 29 3592
kitty-themes 27116 24 0 7
kovidgoyal.github.io 12577 0 0 1
libimobiledevice 2847 0 0 0
libplist 950 0 0 0
libusbmuxd 124 0 0 0
MathJax 118588 0 0 0
patchelf 433 0 0 0
powerline-daemon 354 5 1 4
pywin32 58326 1 0 0
rapydscript-ng 4434 46 8 155
repology-rules 9202 0 0 0
sieve.vim 87 0 0 0
sphinx_rtd_dark_mode 138 0 0 0
subseq-matcher 250 1 0 0
unrardll 10628 5 0 1
vim-rapydscript 30 0 0 0
vim-template 114 1 0 0
vise 1123 5 1 3

Plots

Donuts chart for getting size occupied by each repo.

data <- repo_table %>% 
  arrange(desc(as.numeric(size)))

data$fraction = as.numeric(data$size) / sum(as.numeric(data$size))

# Compute the cumulative percentages (top of each rectangle)
data$ymax = cumsum(data$fraction)

# Compute the bottom of each rectangle
data$ymin = c(0, head(data$ymax, n=-1))
 
# Make the plot
ggplot(data, aes(ymax=ymax, ymin=ymin, xmax=4, xmin=3, fill=name)) +
     geom_rect() +
     coord_polar(theta="y") +
     #scale_fill_brewer(palette=1) +
     xlim(c(2, 4)) +
     theme_void() +
     ggtitle("Data size in each repo")

Lollipop chart for comparing public repo count wrt followers

data <- followers_table

ggplot(data, aes(x=as.numeric(public_repos), y=as.numeric(followers))) +
  geom_segment( aes(x=as.numeric(public_repos), xend=as.numeric(public_repos), y=0, yend=as.numeric(followers))) +
  geom_point( size=5, color="black", fill=alpha("blue", 0.3), alpha=0.7, shape=21, stroke=2) + 
  xlab("Followers") +
  ylab("Public Repos") + 
  ggtitle("Public Repos vs Followers Count")