aboutsummaryrefslogtreecommitdiff
path: root/Signed_off_heatmaps.R
blob: 6e1c678860aab6d746ca101da10a71db8c117071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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()