-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitModifiedFilesUtil.py
More file actions
59 lines (40 loc) · 1.97 KB
/
commitModifiedFilesUtil.py
File metadata and controls
59 lines (40 loc) · 1.97 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 related to mining modifiedfiles with respect to commit
#author - sheik shameer
import initializeConnections
import config
def getNumberofFilesTouched(label) :
from tabulate import tabulate
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
file_issuefixSQL = "select FILENAME,Count( distinct ILM.Issue) as TOTAL,GROUP_CONCAT(distinct ILM.Issue SEPARATOR ',') as Issues from IssueLabelMapping as ILM inner join CommitIssueMapping on ILM.Issue = CommitIssueMapping.ISSUE inner join CommitModifiedFilesMapping on CommitIssueMapping.COMMIT = CommitModifiedFilesMapping.COMMIT where Labels = '" + label +"' group by FILENAME order by TOTAL DESC;"
cursor.execute(file_issuefixSQL)
result = cursor.fetchall()
db.close()
formatted_data = []
for row in result:
formatted_data.append([row[0],row[1],row[2]])
print(tabulate(formatted_data, ["FILEPATH","TOTAL",label.upper()], tablefmt="github"))
return formatted_data;
def getNumberofFilesTouchedForBugs() :
return getNumberofFilesTouched(config.fieldlabelbug)
def getNumberofFilesTouchedForFeature() :
return getNumberofFilesTouched(config.fieldlabelfeature)
def getDistinctLabels():
db = initializeConnections.getConnectionMySql()
cursor = db.cursor()
distinct_labelSQL = "select distinct(Labels) from IssueLabelMapping"
cursor.execute(distinct_labelSQL)
result = cursor.fetchall()
db.close()
labels = []
for row in result:
labels.append(row[0])
return labels
def getNumberOfFilesTouchedByAllLabels() :
import excelexport
labels = getDistinctLabels()
for label in labels :
print ("\n\n\n Files touched for ----" + (label))
formattedata = [["FILENAME","TOTAL",label.upper()]]
formattedata = formattedata + getNumberofFilesTouched(label)
excelexport.saveExcel(formattedata,"filestouchedby"+label)