-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExtractQualitative.py
More file actions
69 lines (59 loc) · 1.91 KB
/
Copy pathExtractQualitative.py
File metadata and controls
69 lines (59 loc) · 1.91 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
import sys
import os
import json
import pymysql
import time
from collections import Counter
import matplotlib.pyplot as plt
import numpy as np
import operator
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
import Utility.RepoConfig as Repo
import Utility.DBConfig as DB
def main():
"""
Main function to extract the qualitative quality of the issue (reopen ratio)
"""
print("Try to add `reopen_ratio` and `qualitative_quality` column ...")
addColumn = "ALTER TABLE `sprint_feature` ADD `reopen_ratio` FLOAT;"
try:
cursor.execute(addColumn)
connection.commit()
print("Add columns successfully")
except:
print("This repo already has columns")
time.sleep(3)
print("\nStart to add value into `reopen_ratio` column ...")
select = "SELECT board_id, sprint_id, no_reopen, no_issue FROM sprint_feature"
cursor.execute(select)
result = cursor.fetchall()
for row in result:
try:
reopenRatio = row['no_reopen']/row['no_issue']
except:
reopenRatio = 0.0
update = "UPDATE sprint_feature SET reopen_ratio = %s WHERE board_id = %s AND sprint_id = %s"
inputPara = (
reopenRatio,
row['board_id'],
row['sprint_id']
)
cursor.execute(update, inputPara)
connection.commit()
print("DONE FOR {}".format(repo.name.upper()))
if __name__ == '__main__':
repo = Repo.createRepo()
db = DB.createDB(repo)
connection = pymysql.connect(
host=db.host,
port=db.port,
user=db.user,
passwd=db.pwd,
database=db.repo.name,
cursorclass=pymysql.cursors.DictCursor
)
cursor = connection.cursor()
main()
cursor.close()
connection.close()
print("DB Connection is closed")