/
bugstats.py
executable file
·78 lines (70 loc) · 5.4 KB
/
bugstats.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
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
import sys
from jiraauth import jclient as jira
from collections import namedtuple
'''
Synopsis: This script runs a series of JQL searches to tally the number of
bugs in various states. Currently there is some small overlap between a
couple of the searches, so the sum total will be greater than the actual
number of bugs in the system. This should be fixed.
'''
QueryData = namedtuple('QueryData', ['issuetype', 'status', 'reporter', 'assignee', 'SLA', 'level', 'flagged'])
querygroups = [ [ QueryData('in (Bug, Improvement)', '= "Release Pending"', None, None, None, None, None), ],
[ QueryData('in (Bug, Improvement)', '= "Reopened"', None, None, None, None, None), ],
[ QueryData('in (Bug, Improvement)', 'in ("Needs Clarification", "Waiting for Reporter")', None, None, None, None, None), ],
[ QueryData('in (Bug, Improvement)', 'in ("In Progress", "In Review", "In QA")', None, 'is EMPTY', None, None, None),
QueryData('in (Bug, Improvement)', 'in ("In Progress", "In Review", "In QA")', None, 'is not EMPTY', None, None, None), ],
[ QueryData('in (Bug, Improvement)', '= Confirmed', None, 'is EMPTY', None, None, None),
QueryData('in (Bug, Improvement)', '= Confirmed', None, 'in membersOf("engineering")', None, None, None),
QueryData('in (Bug, Improvement)', '= Confirmed', None, 'not in membersOf("engineering")', None, None, None), ],
[ QueryData('in (Bug, Improvement)', 'in (Unconfirmed, Investigating)', 'in membersOf("engineering")',
'not in membersOf("engineering")', None, None, None),
QueryData('in (Bug, Improvement)', 'in (Unconfirmed, Investigating)', 'in membersOf("engineering")',
'is EMPTY', None, None, None),
QueryData('in (Bug, Improvement)', 'in (Unconfirmed, Investigating)', 'in membersOf("engineering")',
'in membersOf("engineering")', None, None, None), ],
[ QueryData('= Improvement', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'in membersOf("engineering")', None, None, None),
QueryData('= Improvement', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'not in membersOf("engineering"); is EMPTY', None, None, None), ],
[ QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'is EMPTY', 'in ("Standard", "Premium")', None, None),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'in membersOf("engineering")', 'in ("Standard", "Premium")', None, None),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'in membersOf("tier-2-support"); in membersOf("tier-3-support")', 'in ("Standard", "Premium")', None, "is EMPTY"),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'not in membersOf("tier-2-support"); not in membersOf("engineering"); not in membersOf("tier-3-support")', 'in ("Standard", "Premium")', None, "is EMPTY"),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'not in membersOf("engineering")', 'in ("Standard", "Premium")', None, "is not EMPTY"), ],
[ QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'is EMPTY', 'is EMPTY; = "Not Applicable"', 'is EMPTY; = "Public"', None),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'is EMPTY', 'is EMPTY; = "Not Applicable"', 'in ("Eucalyptus Employees", "Eucalyptus and Reporter")', None),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'in membersOf("engineering")', 'is EMPTY; = "Not Applicable"', None, None),
QueryData('= Bug', 'in (Unconfirmed, Investigating)', 'not in membersOf("engineering")',
'not in membersOf("engineering")', 'is EMPTY; = "Not Applicable"', None, None), ],
]
basequery = '''project in (Euca2ools, Broker, "SAN Storage", Eucalyptus) AND
issuetype in (Bug, Improvement) AND
status not in (Closed, Resolved)'''
print "issuetype|status|reporter|assignee|SLA|level|flagged|count|subtotal"
sumTotal = 0
for qgroup in querygroups:
subTotal = 0
data = []
for query in qgroup:
fullquery = basequery
for attr in ['issuetype', 'status', 'reporter', 'assignee', 'SLA', 'level', 'flagged']:
criteria = getattr(query, attr)
if criteria:
fullquery += " AND (%s) " % " OR ".join([ "%s %s" % (attr, x) for x in criteria.split(";") ])
total, issues = jira.search_issues_with_total(fullquery)
data.append("%s|%d" % ("|".join([repr(x) for x in query]), total))
subTotal += total
print "\n".join(data) + "|" + str(subTotal)
sumTotal += subTotal
total, issues = jira.search_issues(basequery)
print "GRAND TOTAL: %d" % total
print "SUM TOTAL: %d" % sumTotal