-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbug_backlog.py
57 lines (47 loc) · 1.75 KB
/
bug_backlog.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
import json
import requests
import datetime
import time
from datetime import date
import plotly.plotly as py
import plotly.graph_objs as graph
from pprint import pprint
class Backlog:
def __init__(self, status, resolutions, bugs, from_date):
self.status = status
self.resolutions = resolutions
self.bugs = bugs
self.from_date = from_date
def countBugsOfDay(self, day, bugs):
""" Count the number of bugs on a day """
return sum(1 for bug in bugs if self.getDateOfBug(bug) == day)
def getDateOfBug(self, bug):
"""
Get the date of a bug in order to compare it with a dateTime
"""
# FIXME: I am new to python. There may be a easy way to do this. But I'm still looking into it.
return datetime.datetime.strptime(json.dumps(bug['last_change_time']), '"%Y-%m-%dT%H:%M:%SZ"').date()
def extractBugsPerDayOf(self, status, bugs):
"""
Generate a graph of bugs (axis Y) per day (axis X) of given bug list
"""
x = [];
y = [];
print self.from_date
for day in range(0 , self.from_date[2]):
# get the current day of the month
currentDay = datetime.date(self.from_date[0], self.from_date[1], (day + 1))
x.append(currentDay)
# get the number of bugs in that day
numberOfBugsInDay = self.countBugsOfDay(currentDay, bugs)
y.append(numberOfBugsInDay)
print 'In %s there were %s bugs' %(currentDay, numberOfBugsInDay)
return graph.Scatter(x=x, y=y, name=status)
def extractBugsPerDay(self):
""" Generate a report of opened and closed bugs per day of a give bugzilla server """
print '\nGenerating bug backlog\n'
data = []
for status in self.status:
result = self.extractBugsPerDayOf(status, self.bugs[status])
data.append(result)
return data