-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrequency.py
More file actions
117 lines (82 loc) · 4.02 KB
/
frequency.py
File metadata and controls
117 lines (82 loc) · 4.02 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
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
#Utility file for mining the frequency of an entity
#author - sheik shameer s
import initializeConnections
def getCommitFrequency():
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
commitFreq = "SELECT YEAR(COMMITEDDATE), MONTH(COMMITEDDATE) MONTH, COUNT(*) TOTALCOMMIT FROM Commits GROUP BY YEAR(COMMITEDDATE), MONTH(COMMITEDDATE) ORDER BY TOTALCOMMIT DESC"
cursor.execute(commitFreq)
result = cursor.fetchall()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1],row[2]])
displayheaders= ["YEAR","MONTH","NOOFCOMMITS"]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"frequencyofcommits")
return formatteddata
def getIssueFrequency():
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
issueFreq = "SELECT YEAR(CREATEDATE), MONTH(CREATEDATE) MONTH, COUNT(*) TOTALISSUES FROM Issues GROUP BY YEAR(CREATEDATE), MONTH(CREATEDATE) ORDER BY TOTALISSUES DESC"
cursor.execute(issueFreq)
result = cursor.fetchall()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1],row[2]])
displayheaders= ["YEAR","MONTH","NOOFISSUES"]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"frequencyofIssues")
return formatteddata
def getIssueFrequencyForLabelsCreation(label):
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
labelFreq = "SELECT YEAR(CREATEDATE), MONTH(CREATEDATE) MONTH, COUNT(*) TOTALISSUES FROM Issues inner join IssueLabelMapping ON Issues.NUMBER = IssueLabelMapping.Issue where IssueLabelMapping.Labels = '"+label+"' GROUP BY YEAR(CREATEDATE), MONTH(CREATEDATE) ORDER BY TOTALISSUES DESC"
cursor.execute(labelFreq)
result = cursor.fetchall()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1],row[2]])
displayheaders= ["YEAR","MONTH","NOOF" + label]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"frequencyofCreation"+label)
return formatteddata
def getIssueCreationFrequencyForAllLabels() :
from commitModifiedFilesUtil import getDistinctLabels
labels = getDistinctLabels()
for label in labels :
getIssueFrequencyForLabelsCreation(label)
def getIssueFrequencyForLabelsClosed(label):
from tabulate import tabulate
import excelexport
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
labelFreq = "SELECT YEAR(CLOSEDAT), MONTH(CLOSEDAT) MONTH, COUNT(*) TOTALISSUES FROM Issues inner join IssueLabelMapping ON Issues.NUMBER = IssueLabelMapping.Issue where IssueLabelMapping.Labels = '"+label+"' GROUP BY YEAR(CLOSEDAT), MONTH(CLOSEDAT) ORDER BY TOTALISSUES DESC"
cursor.execute(labelFreq)
result = cursor.fetchall()
db.close()
formatteddata = []
for row in result :
formatteddata.append([row[0],row[1],row[2]])
displayheaders= ["YEAR","MONTH","NOOF" + label]
print(tabulate(formatteddata,displayheaders , tablefmt="github"))
exceldata = [displayheaders]
exceldata = exceldata + formatteddata
excelexport.saveExcel(exceldata,"frequencyofClosed"+label)
return formatteddata
def getIssueClosureFrequencyForAllLabels() :
from commitModifiedFilesUtil import getDistinctLabels
labels = getDistinctLabels()
for label in labels :
getIssueFrequencyForLabelsClosed(label)