-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetJiraData.py
70 lines (52 loc) · 2 KB
/
GetJiraData.py
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
#coding = utf-8
from collections import Counter
from JiraReport.JiraInit import JiraInit
from JiraReport.LogAndExcept import logger,except_decorate
# 获取具体数据
assignee_li = []
components_li = []
bugtypes_li = []
class GetJiraData(JiraInit):
def setup(self,project,version):
jql = GetJiraData.JqlProjrct(project) + GetJiraData.JqlText(version)
issues_counts = self.JqlContent(jql)
return issues_counts
# list转dict
@staticmethod
def all_dict(li):
count = Counter(li)
count_dict = dict(count) # 类型:<type 'dict'>
# count_tuple = sorted(count_dict.items(), key=lambda x: x[1], reverse=True)
# return count_tuple
return count_dict
# 获取jql对象
def JqlContent(self,jqlcontent):
jql = self.jr.search_issues(("%s"%jqlcontent), maxResults=300)
return jql
# 反射处理无自定义字段情况
def get_isss(self,project, version, text):
isss = self.setup(project, version)
for i in isss:
fie = self.jr.issue(i, fields="components,assignee,customfield_10301")
try:
eval(text)
except AttributeError:
continue
# 获取模块
@except_decorate("获取模块错误")
def get_components(self,project,version):
self.get_isss(project, version,
"components_li.append(fie.fields.components[0].name)")
return self.all_dict(components_li)
# 获取经办人
@except_decorate("获取经办人错误")
def get_assignes(self,project,version):
self.get_isss(project, version,
"assignee_li.append(fie.fields.assignee.displayName)")
return self.all_dict(assignee_li)
# 获取bug类型
@except_decorate("Bug类型错误")
def get_bugtypes(self, project, version):
self.get_isss(project, version,
"bugtypes_li.append(fie.fields.customfield_10301.value)")
return self.all_dict(bugtypes_li)