-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserinfo.py
More file actions
59 lines (41 loc) · 1.82 KB
/
userinfo.py
File metadata and controls
59 lines (41 loc) · 1.82 KB
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
#Utility functions with reference to user activity
import initializeConnections
def getNoOfCommitsByUsers():
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
commitsSQL = "select EMAIL, count(*) as total from Commits group by EMAIL order by total desc"
cursor.execute(commitsSQL)
result = cursor.fetchall()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1]])
displayheaders= ["EMAIL","TOTALCOMMITS"]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"UserCommits")
return formatteddata
def getNoOfIssueByLabel(label) :
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
labelFreq = "SELECT USERLOGIN, COUNT(*) as TOTAL FROM Issues inner join IssueLabelMapping ON Issues.NUMBER = IssueLabelMapping.Issue where IssueLabelMapping.Labels = '"+label+"' group by USERLOGIN order by TOTAL desc"
cursor.execute(labelFreq)
result = cursor.fetchall()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1]])
displayheaders= ["USERNAME","TOTAL"+label]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"usercreatedissues"+label)
return formatteddata
def getNoOfIssueForAllLabels(label):
from commitModifiedFilesUtil import getDistinctLabels
labels = getDistinctLabels()
for label in labels :
getNoOfIssueByLabel(label)