-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpullreqrepo.py
54 lines (45 loc) · 1.12 KB
/
pullreqrepo.py
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
# coding: utf-8
# In[1]:
get_ipython().magic(u'matplotlib inline')
import numpy as np
import psycopg2
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
database = psycopg2.connect(database='netdata', user='postgres', password='postgres')
cursor = database.cursor()
user = []
u = []
ques = []
q = []
cursor.execute("select distinct base_repo_id from ghtorrent_pull_requests")
rows = cursor.fetchall()
for i in range(1,len(rows)):
print len(rows)
cursor.execute("select count(id) from ghtorrent_pull_requests where base_repo_id = %s",rows[i])
r = cursor.fetchone()
print i," : ",r
ques.append(r)
if i < 16:
q.append(r)
user.append(rows[i])
# print "list", qa[i]
#print "it was here"
#plt.ion()
#print "here also"
#x = [1,2,3,4,5,6,7,8,9,10]
#plt.plot(x,qa)
p1 = np.array(q)
arr = np.array(ques)
xt = np.array(user)
print np.mean(arr)
print np.std(arr)
print np.median(arr)
plt.figure()
plt.bar(xt, p1, align='center', alpha=0.1)
plt.xlabel('Repositories')
plt.ylabel('Number of pull requests')
plt.title('pull request per repository')
plt.draw()
#plt.show()
cursor.close()