Merge lp:~abentley/lp-release-manager-tools/month-stats into lp:~sinzui/lp-release-manager-tools/trunk

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 29
Proposed branch: lp:~abentley/lp-release-manager-tools/month-stats
Merge into: lp:~sinzui/lp-release-manager-tools/trunk
Diff against target: 151 lines (+52/-21)
3 files modified
.bzrignore (+4/-0)
lp_release_tools/report_bugs.py (+46/-19)
setup.py (+2/-2)
To merge this branch: bzr merge lp:~abentley/lp-release-manager-tools/month-stats
Reviewer Review Type Date Requested Status
Curtis Hovey code Approve
Review via email: mp+223442@code.launchpad.net

Commit message

Allow per-month stats.

Description of the change

This branch implements per-month statistics. So it generates WorkCycles on a per-month basis if --month is supplied.
It introduces --count to change the number of cycles emitted.
It also changes the label for "held" bugs to "Held".
It also implements true bug totals.
It also emits triage-time for every row.
It extracts the line formatting to its own method.
It also switches to setuptools because distutils doesn't support entry_points.
It also ignores some directories to support virtualenv.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

thank you

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-01-28 13:39:36 +0000
3+++ .bzrignore 2014-06-17 16:36:46 +0000
4@@ -2,3 +2,7 @@
5 dist
6 juju-bugs.json
7 *.egg-info
8+./bin
9+./include
10+./lib
11+./local
12
13=== modified file 'lp_release_tools/report_bugs.py'
14--- lp_release_tools/report_bugs.py 2014-05-24 02:08:24 +0000
15+++ lp_release_tools/report_bugs.py 2014-06-17 16:36:46 +0000
16@@ -62,34 +62,38 @@
17 self.held = []
18 self.opened = []
19 self.closed = []
20+ self.total = []
21 self.tag_groups = tag_groups
22 self.importance_groups = importance_groups
23
24+ def line(self, group, held, opened, closed, total):
25+ return "%23s: %4d %+4d %4d %3d %3dd" % (
26+ group, len(held), len(opened), -len(closed), len(total),
27+ self.triage_time(opened))
28+
29 def __str__(self):
30 rows = ['%s - %s' % (
31 self.start.strftime('%Y-%m-%d'), self.finish.strftime('%Y-%m-%d'))]
32- rows.append("%23s: %4d +%2d -%2d %2dd" % (
33- 'All bugs', len(self.held), len(self.opened), len(self.closed),
34- self.triage_time))
35+ rows.append(self.line('All bugs', self.held, self.opened, self.closed,
36+ self.total))
37 for group, tags in self.tag_groups.items():
38- rows.append("%23s: %4d +%2d -%2d" % (
39- group,
40- len(self._filter(tags, self.held)),
41- len(self._filter(tags, self.opened)),
42- len(self._filter(tags, self.closed))))
43+ rows.append(self.line(
44+ group, self._filter(tags, self.held),
45+ self._filter(tags, self.opened),
46+ self._filter(tags, self.closed),
47+ self._filter(tags, self.total)))
48 for group, importances in self.importance_groups.items():
49- rows.append("%23s: %4d +%2d -%2d" % (
50- group,
51- len([b for b in self.held if b.importance in importances]),
52- len([b for b in self.opened if b.importance in importances]),
53- len([b for b in self.closed if b.importance in importances])))
54+ rows.append(self.line(
55+ group, [b for b in self.held if b.importance in importances],
56+ [b for b in self.opened if b.importance in importances],
57+ [b for b in self.closed if b.importance in importances],
58+ [b for b in self.total if b.importance in importances]))
59 return '\n'.join(rows)
60
61- @property
62- def triage_time(self):
63+ def triage_time(self, bugs):
64 delta = timedelta()
65 triaged_count = 0
66- for bug in self.opened:
67+ for bug in bugs:
68 if bug.date_triaged:
69 delta += bug.date_triaged - bug.date_created
70 triaged_count += 1
71@@ -137,6 +141,18 @@
72 return cycles
73
74
75+def make_month_cycles(today, tag_groups, importance_groups, cycle_count=26):
76+ """Return a list of monthly bug reporting cycles."""
77+ finish = today.replace(day=1)
78+ cycles = []
79+ for month in range(cycle_count):
80+ start = (finish - timedelta(1)).replace(day=1)
81+ cycles.append(WorkCycle(start, finish, tag_groups, importance_groups))
82+ finish = start
83+ cycles.reverse()
84+ return cycles
85+
86+
87 def collate_bugs(bugs, cycles):
88 """Collate bugs into cycles of opened, closed, and held.
89
90@@ -151,6 +167,8 @@
91 break
92 if bug.date_created > cycle.finish:
93 continue
94+ if not bug.date_closed or not bug.date_closed < cycle.finish:
95+ cycle.total.append(bug)
96 if (bug.date_created >= cycle.start
97 and bug.date_created < cycle.finish):
98 cycle.opened.append(bug)
99@@ -183,7 +201,7 @@
100
101
102 def report_cycles(cycles):
103- print("Work Cycle Total Opened Closed Triage-Time")
104+ print("Work Cycle Held Opened Closed Total Triage-Time")
105 for cycle in cycles:
106 print(cycle)
107
108@@ -201,7 +219,12 @@
109 bugs = get_bugs(json_file)
110 tag_groups = make_tag_groups(options)
111 importance_groups = make_importance_groups(options)
112- cycles = make_cycles(today, tag_groups, importance_groups)
113+ if options.monthly:
114+ cycles = make_month_cycles(today, tag_groups, importance_groups,
115+ cycle_count=options.count)
116+ else:
117+ cycles = make_cycles(today, tag_groups, importance_groups,
118+ cycle_count=options.count)
119 collate_bugs(bugs, cycles)
120 report_cycles(cycles)
121
122@@ -217,9 +240,13 @@
123 parser.add_option(
124 "-i", "--importance", dest="importance", action="append",
125 type="string", help="Match bugs with all of the listed importances.")
126+ parser.add_option('--monthly', action='store_true',
127+ help='Display monthly cycles.')
128+ parser.add_option('--count', type=int, help='Number of cycles to display')
129 parser.set_defaults(
130 tags=[],
131- importance=[])
132+ importance=[],
133+ count=26)
134 return parser
135
136
137
138=== modified file 'setup.py'
139--- setup.py 2014-01-28 13:39:36 +0000
140+++ setup.py 2014-06-17 16:36:46 +0000
141@@ -1,8 +1,8 @@
142 #!/usr/bin/python
143 import subprocess
144
145-from distutils.core import setup
146-from distutils.command.sdist import sdist
147+from setuptools import setup
148+from setuptools.command.sdist import sdist
149
150
151 class SignedSDistCommand(sdist):

Subscribers

People subscribed via source and target branches

to all changes: