Repository navigation
Expand file tree
/
Copy pathNoComment.py
More file actions
80 lines (67 loc) · 2.45 KB
/
Copy pathNoComment.py
File metadata and controls
80 lines (67 loc) · 2.45 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
import sys
import json
import pymysql
import os
import datetime
import time
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
import Utility.JSONUtility as Utility
import Utility.RepoConfig as Repo
def countComment():
"""
Count the number of comments in the issue
"""
addCol = "ALTER TABLE `sprint_issue_feature_insight` ADD `no_comment` TINYINT NOT NULL AFTER `change_priority`;"
try:
cursor.execute(addCol)
connection.commit()
except:
pass
check = "SELECT start_date, board_id, sprint_id FROM sprint_feature_insight"
cursor.execute(check)
resultcheck = cursor.fetchall()
for row in resultcheck:
start_date = row['start_date']
boardID = row['board_id']
sprintID = row['sprint_id']
select = "SELECT board_id, sprint_id, issue_key, (SELECT count(comment_id) FROM sprint_issue_comment sic WHERE sif.board_id = sic.board_id AND sif.sprint_id = sic.sprint_id AND sif.issue_key = sic.issue_key AND sic.createddate <= %s) AS no_comment FROM sprint_issue_feature sif WHERE board_id = %s AND sprint_id = %s"
inputPara =(
start_date,
boardID,
sprintID,
)
cursor.execute(select,inputPara)
result = cursor.fetchall()
for row in result:
boardID = row['board_id']
sprintID = row['sprint_id']
issueKey = row['issue_key']
noComment = row['no_comment']
update = "UPDATE sprint_issue_feature_insight SET no_comment = %s WHERE board_id = %s and sprint_id = %s and issue_key = %s"
inputPara =(
noComment,
boardID,
sprintID,
issueKey
)
cursor.execute(update,inputPara)
connection.commit()
# print("update {} {} {} into DB successfully".format(boardID, sprintID, issueKey))
if __name__ == '__main__':
try:
repo = sys.argv[1]
except:
print("No argument")
sys.exit()
connection = pymysql.connect(
host="localhost",
user="root",
passwd="whateverpasswordiwant",
database=repo,
cursorclass=pymysql.cursors.DictCursor
)
cursor = connection.cursor()
countComment()
cursor.close()
connection.close()
print("DB Connection is closed")