Repository navigation
Expand file tree
/
Copy pathExtractSprintAssignee.py
More file actions
96 lines (79 loc) · 2.88 KB
/
Copy pathExtractSprintAssignee.py
File metadata and controls
96 lines (79 loc) · 2.88 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
'''
Script to extract assignee of Sprint
'''
import sys
import json
import os
import pymysql
import datetime
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import Utility.DBConfig as DB
import Utility.RepoConfig as Repo
"""
CREATE TABLE `sprint_teammember` (
`board_id` int(11) NOT NULL,
`sprint_id` int(11) NOT NULL,
`username` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `sprint_teammember`
ADD PRIMARY KEY (`board_id`,`sprint_id`,`username`) USING BTREE;
COMMIT;
"""
def extractSprintMember():
print("Collect Sprint member...")
# Modified 18/8/2019 - focus on only CLOSED sprint
select = "SELECT board_id, sprint_id FROM sprint_feature"
cursor.execute(select)
result = cursor.fetchall()
for sprint in result:
boardID = str(sprint['board_id'])
sprintID = str(sprint['sprint_id'])
select = "SELECT issue_key FROM sprint_issue WHERE board_id = %s AND sprint_id = %s"
inputPara = (
boardID,
sprintID
)
cursor.execute(select, inputPara)
result = cursor.fetchall()
for issue in result:
issueKey = str(issue['issue_key'])
select = "SELECT assignee FROM sprint_issue_feature WHERE board_id = %s AND sprint_id = %s AND issue_key = %s AND assignee IS NOT NULL"
inputPara = (
boardID,
sprintID,
issueKey
)
cursor.execute(select, inputPara)
result = cursor.fetchall()
for item in result:
assignee = str(item['assignee'])
insertAssignee = "INSERT INTO sprint_teammember(board_id, sprint_id, username) VALUES(%s, %s, %s)"
inputPara = (
boardID,
sprintID,
assignee
)
# don't insert dup username for the same sprint
try:
cursor.execute(insertAssignee, inputPara)
connection.commit()
except:
continue
print("Issue {} in Sprint {} on Board {} has {} as assignee".format(issueKey, sprintID, boardID, assignee))
print("\r\n---------------------- INSERT ASSIGNEE NAME COMPLETED for {}----------------------\r\n".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()
extractSprintMember()
cursor.close()
connection.close()
print("DB Connection is closed")