diff options
author | Mike Holmes <mike.holmes@linaro.org> | 2017-05-15 14:24:28 -0400 |
---|---|---|
committer | Mike Holmes <mike.holmes@linaro.org> | 2017-05-15 14:24:28 -0400 |
commit | ef6d200dc139980dc368415ca12167e2bc0610f8 (patch) | |
tree | 91ba7ec51a850f8daf1541cee1c2b7b239b55630 | |
parent | ee9907c95dcbdf767bba13d75d0a378a4e74757f (diff) | |
parent | 4df827baaa92081c7dab8801d8ab67c7cda57cc7 (diff) |
Merge branch 'master' of ssh://git.linaro.org/people/mike.holmes/JIRA_R
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | R.Rproj | 13 | ||||
-rw-r--r-- | Signed_off_heatmaps.R | 170 | ||||
-rw-r--r-- | company_interest.R | 272 | ||||
-rw-r--r-- | member_heatmaps.R | 14 |
5 files changed, 469 insertions, 1 deletions
@@ -1 +1,2 @@ *.pdf +.Rproj.user @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/Signed_off_heatmaps.R b/Signed_off_heatmaps.R new file mode 100644 index 0000000..6e1c678 --- /dev/null +++ b/Signed_off_heatmaps.R @@ -0,0 +1,170 @@ +library(RCurl) +library(curl) +library(jsonlite) +library(gsubfn) +library(gplots) +library(RColorBrewer) +library(reshape) +library(plyr) + +#functions + + +get_tags <- function (id) { +#http://patches.linaro.org/api/1.0/teams/39/commit-tags/ + + baseurl <- "http://patches.linaro.org/api/1.0/" + type <- paste("teams/",id,"/commit-tags/?format=json&per_page=5000", sep = "") + + url <- paste(baseurl, type, sep = "") + cat (url,"\n") + + webpage <- curl (url, handle = h) + + #get data it into R + jira_tags_raw <- fromJSON(webpage,simplifyMatrix = TRUE, simplifyVector =TRUE, simplifyDataFrame = TRUE, flatten = TRUE) + m <- data.frame(tag=jira_tags_raw$tag, person=jira_tags_raw$person) + + return(m) +} + +get_signed <- function (df){ + return (length(grep("Signed-off", df$contribution$tag))) + } + +get_acked <- function (df){ + return (length(grep("Acked", df$contribution$tag))) +} + +get_reviewed <- function (df){ + return (length(grep("Reviewed", df$contribution$tag))) +} + +get_tested <- function (df){ + return (length(grep("Tested", df$contribution$tag))) +} + +get_reported <- function (df){ + return (length(grep("Reported", df$contribution$tag))) +} + + +get_projects <- function (df){ + return (df$contribution$project) +} + + +#from the website get the initiatives list for the four teams +id <- Sys.getenv(c("JIRA_USERNAME", "JIRA_PASSWORD")) + +if (id[1] == '') { + print ("export JIRA_USERNAME='john.doe@linaro.org'") + stop() +} +if (id[2] == '') { + print ("export JIRA_PASSWORD='my-super-secret-password'") + stop() +} + +user_password <- paste(id[1], id[2], sep=":") + + +h <- new_handle(failonerror = TRUE) +handle_setopt(h, verbose = 0) +handle_setopt(h, userpwd = user_password) +handle_setopt(h, httpauth = 1) + +report_name <- c("signed_off") + + + +baseurl <- "http://patches.linaro.org/api/1.0/" +type <- "teams/?format=json&per_page=5000" + +url <- paste(baseurl, type, sep = "") +cat (url,"\n") + +webpage <- curl (url, handle = h) + +#get data it into R +jira_raw <- fromJSON(webpage,simplifyMatrix = TRUE, simplifyVector =TRUE, simplifyDataFrame = TRUE, flatten = TRUE) +#list of every issue + +df <- data.frame(id=jira_raw$id, name=jira_raw$display_name, url=jira_raw$url) + +row.names(df) <- jira_raw$display_name +str(df) + +n <- sapply(df$id,get_tags) +str(n) + +df$contributions <- n + +#table(n[[]]$project) +#I am gere getting bits out + +#print (df) +list.contributions <- do.call("rbind",df$contributions) + +unique.tags <- (unique(list.contributions$tag)) +unique.persons <- (unique(list.contributions$person)) +unique.projects <- (unique(list.contributions$project)) + +print(unique.tags) +print(unique.persons) +print(unique.projects) + +df$signed <- apply(df,1, get_signed) +df$acked <- apply(df,1, get_acked) +df$reviewed <- apply(df,1, get_reviewed) +df$tested <- apply(df,1, get_tested) +df$reported<- apply(df,1, get_reported) + + +m <- as.matrix(df[,5:9]) + +pdf(file="Linaro_team_vs_git_signoff.pdf", title = "team vs. git stats") +op <- par(mar=c(15,4,4,2)) +colours <- c("lightblue", "mistyrose", "lightcyan","lavender", "cornsilk") +inverse.m <- t(m) +barplot(inverse.m, las=2, + main="non author contribution", + ylab = "number of patches", + col =colours, + legend.text=TRUE, + args.legend=list(x='topleft') + ) + + +barplot(df$signed, main="signed off", las=2, ylab = "number of patches", + names.arg = row.names(df), col = colours[1]) +barplot(df$acked, las=2, main="acked", ylab = "number of patches", + names.arg = row.names(df), col = colours[2]) +barplot(df$reviewed, las=2, main="reviewed", ylab = "number of patches", + names.arg = row.names(df), col = colours[3]) +barplot(df$tested, las=2, main="tested", ylab = "number of patches", + names.arg = row.names(df), col = colours[4]) +barplot(df$reported, las=2, main="reported", ylab = "number of patches", + names.arg = row.names(df), col = colours[5]) + +dev.off() + +cat ("-----------------------\n") +pdf(file="Linaro_team_vs_project.pdf", title = "team vs. git stats") + +#str(n) +nm <- matrix(ncol=length(unique.projects), nrow=length(rownames(df))) +colnames(nm) <- unique.projects +print(nm) + +str(list.contributions) + +for ( p in rownames(nm)) +{ + print(p) +} + +dev.off() + + + diff --git a/company_interest.R b/company_interest.R new file mode 100644 index 0000000..0dc4cfb --- /dev/null +++ b/company_interest.R @@ -0,0 +1,272 @@ +library(RCurl) +library(curl) +library(jsonlite) +library(gsubfn) +library(gplots) +library(RColorBrewer) + +#functions +companies <- function (names) +{ + companys = list() + for (name in names) { + for (n in name) { + companys[[length(companys) + 1]] <- + strapplyc(n, "@(.*)", simplify = TRUE) + } + } + company <- unique(companys) + + return (company) +} + +display_hetmap <- function(report, m, suffix) { + report_name <- paste(report["name"], suffix, ".pdf",sep = "") + pdf(file=report_name, title = report["name"],paper="us") + + #display raw data + print(m) + cat("Generating", report_name) + + # following code limits the lowest and highest color to 5%, and 95% of your range, respectively + quantile.range <- quantile(m, probs = seq(0, 1, 0.01)) + palette.breaks <- + seq(quantile.range["5%"], quantile.range["95%"], 0.1) + + # use http://colorbrewer2.org/ to find optimal divergent color palette (or set own) + color.palette <- + colorRampPalette(c("#FC8D59", "#FFFFBF", "#91CF60"))(length(palette.breaks) - 1) + + watcher_heatmap <- + heatmap.2( + m, + dendrogram = 'row', + Rowv = TRUE, + Colv = FALSE, + trace = "none", + margins = c(12, 12), + col = color.palette, + breaks = palette.breaks, + ylab = "company", + xlab = "project" + ) + dev.off() +} + +display_barplot <- function(report, m, suffix) { + report_name <- paste(report["name"], suffix, ".pdf",sep = "") + pdf(file=report_name, title = report["name"],paper="us") + + #display raw data + cat("Generating", report_name, "\n") + print(m) + + # following code limits the lowest and highest color to 5%, and 95% of your range, respectively + quantile.range <- quantile(m, probs = seq(0, 1, 0.01)) + palette.breaks <- + seq(quantile.range["5%"], quantile.range["95%"], 0.1) + + # use http://colorbrewer2.org/ to find optimal divergent color palette (or set own) + color.palette <- + colorRampPalette(c("#FC8D59", "#FFFFBF", "#91CF60"))(length(palette.breaks) - 1) + + watcher_barplot <- + barplot2(m, ylab = "interest", + xlab = "project",col = color.palette) + dev.off() +} + +watcher_heatmap <- function(report) { + baseurl <- "https://projects.linaro.org/rest/api/2/" + fields <- "&fields=watches,key,project" + + type <- "search?" + jql <- paste ("jql=project+in+(",report["team"],")+AND+issuetype+in+(Initiative,Epic)&maxResults=2000", sep = "") + + url <- paste(baseurl, type, jql, fields, sep = "") + cat (url,"\n") + webpage <- curl (url, handle = h) + + #get data it into R + jira_raw <- fromJSON(webpage, simplifyDataFrame = TRUE) + # extract the data node + keys <- jira_raw$issues$key + + #x axis the number of projects + projects <- unique(jira_raw$issues$fields$project$key) + num_projects <- length(projects) + + #projects + #from the website now get watchers names with another query for all keys found previously + fields <- "/watchers" + type <- "issue/" + + names = list() + for (key in keys) { + url <- paste(baseurl, type, key, fields, sep = "") + webpage <- curl (url, handle = h) + jira_raw_names <- fromJSON(webpage, simplifyDataFrame = TRUE) + + names[[length(names) + 1]] <- + as.list(jira_raw_names$watchers$name) + } + + #create empty matrix + comp <- companies(names) + num_comp <- length(comp) + m <- matrix(NA, nrow = num_comp, ncol = num_projects) + colnames(m) <- projects + rownames(m) <- comp + m[] <- 0L + + #from the website now get watchers names with another query for all keys found previously + fields <- "/watchers" + type <- "issue/" + + for (key in keys) { + #y + mike <- match (key, keys) + team <- jira_raw$issues$fields$project$key[mike] + y <- match (team, projects) + + #x + names = list() + url <- paste(baseurl, type, key, fields, sep = "") + webpage <- curl (url, handle = h) + jira_raw_names <- fromJSON(webpage, simplifyDataFrame = TRUE) + + names[[length(names) + 1]] <- as.list(jira_raw_names$watchers$name) + interested = companies(names) + for (c in interested) + { + x <- match (c, comp) + m[x, y] <- m[x, y] + 1 + } + } + + #remove companies +# rows.to.delete <- c('linaro.org', 'broadcom.com', 'character') + # for (d in rows.to.delete) { + # m <- as.matrix(m[!grepl(d, rownames(m)),]) +# } + + for (c in comp) { + + v <- as.vector(m[c,]) + names(v) <- projects + report["name"] <- c + + display_barplot(report, v, "_wt") + } +} + + +sponsor_heatmap <- function (report) { + baseurl <- "https://projects.linaro.org/rest/api/2/" + fields <- "&fields=customfield_10101,key,project" + type <- "search?" + + jql <- + paste( + "jql=project+in+(", + report["team"], + ")+AND+issuetype+in+(Initiative,Epic)&maxResults=1000", + sep = "" + ) + url <- paste(baseurl, type, jql, fields, sep = "") + cat (url,"\n") + + webpage <- curl (url, handle = h) + + #get data it into R + jira_raw <- fromJSON(webpage, simplifyDataFrame = TRUE) + #list of every issue + keys <- jira_raw$issues$key + + #x axis the number of projects + projects <- unique(jira_raw$issues$fields$project$key) + num_projects <- length(projects) + + #y axis the companies or sponsors + sponsor <- jira_raw$issues$fields$customfield_10101 + + names = list() + for (key in keys) { + s <- sponsor[[match (key, keys)]][[2]] + for (n in s) { + names[[length(names) + 1]] <- n + } + } + + #create empty matrix + comp <- unique(names) + num_comp <- length(comp) + m <- matrix(NA, nrow = num_comp, ncol = num_projects) + colnames(m) <- projects + rownames(m) <- comp + m[] <- 0L + + # count companies per project by looking at every key and update matrix + + for (key in keys) { + #y + mike <- match (key, keys) + team <- jira_raw$issues$fields$project$key[mike] + y <- match (team, projects) + + #x + s <- sponsor[[match (key, keys)]][[2]] + for (c in s) + { + x <- match (c, comp) + m[x, y] <- m[x, y] + 1 + } + } + + #remove companies we don't like ;) +# rows.to.delete <- c('Linaro') +# for (d in rows.to.delete) { +# m <- as.matrix(m[!grepl(d, rownames(m)),]) + # } + + for (c in comp) { + + v <- as.vector(m[c,]) + names(v) <- projects + report["name"] <- c + + display_barplot(report, v, "_sp") + } +} + +#from the website get the initiatives list for the four teams +id <- Sys.getenv(c("JIRA_USERNAME", "JIRA_PASSWORD")) +if (id[1] == '') { + print ("export JIRA_USERNAME='john.doe@linaro.org'") + q() +} +if (id[2] == '') { + print ("export JIRA_PASSWORD='my-super-secret-password'") + q() +} + +user_password <- paste(id[1], id[2], sep=":") + +h <- new_handle(failonerror = TRUE) +handle_setopt(h, verbose = 0) +handle_setopt(h, userpwd = user_password) +handle_setopt(h, httpauth = 1) + +report_name <- c("ti") +team_list <- + c( + "Security,Kernel,'Power',Virtualization,LSK,LHG,LEG,LNG,LITE,LMG,CTT,BB,LAVA,LAB,QA,SYS,TCWG" + ) +reports <- + data.frame(name = report_name , + team = team_list, + stringsAsFactors = FALSE) +apply(reports, 1, sponsor_heatmap) +apply(reports, 1, watcher_heatmap) + + diff --git a/member_heatmaps.R b/member_heatmaps.R index 3d1c59a..e2f2fe0 100644 --- a/member_heatmaps.R +++ b/member_heatmaps.R @@ -203,7 +203,19 @@ sponsor_heatmap <- function (report) { } #from the website get the initiatives list for the four teams -user_password <- "<your email address>:<your password>" +id <- Sys.getenv(c("JIRA_USERNAME", "JIRA_PASSWORD")) + +if (id[1] == '') { + print ("export JIRA_USERNAME='john.doe@linaro.org'") + q() +} +if (id[2] == '') { + print ("export JIRA_PASSWORD='my-super-secret-password'") + q() +} + +user_password <- paste(id[1], id[2], sep=":") + h <- new_handle(failonerror = TRUE) handle_setopt(h, verbose = 0) |