Skip to content

Commit 61ec6e5

Browse files
author
Richard Jones
committed
add new script
1 parent 8d88bc5 commit 61ec6e5

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

scripts/README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ roundup-reminder
88
Generate an email that lists outstanding issues. Send in both plain text
99
and HTML formats.
1010

11+
weekly-report
12+
Generate a simple report outlining the activity in one tracker for the
13+
most recent week.
14+
1115
schema_diagram.py
1216
Generate a schema diagram for a roundup tracker. It generates a 'dot file'
1317
that is then fed into the 'dot' tool (http://www.graphviz.org) to generate

scripts/weekly-report

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /usr/bin/env python2.3
2+
3+
# This script generates a simple report outlining the activity in one
4+
# tracker for the most recent week.
5+
6+
# This script is free software, you may redistribute it
7+
# and/or modify under the same terms as Python.
8+
9+
import sys, math
10+
from roundup import instance, date
11+
12+
# open the instance
13+
if len(sys.argv) != 2:
14+
print 'You need to specify an instance home dir'
15+
instance_home = sys.argv[1]
16+
instance = instance.open(instance_home)
17+
db = instance.open('admin')
18+
19+
old = date.Date('-1w')
20+
21+
created = []
22+
summary = {}
23+
messages = []
24+
25+
# loop through all the recently-active issues
26+
for issue_id in db.issue.filter(None, {'activity': '-1w;'}):
27+
num = 0
28+
for x,ts,userid,action,data in db.issue.history(issue_id):
29+
if ts < old: continue
30+
if action == 'create':
31+
created.append(issue_id)
32+
elif action == 'set' and data.has_key('messages'):
33+
num += 1
34+
summary.setdefault(db.issue.get(issue_id, 'status'), []).append(issue_id)
35+
messages.append((num, issue_id))
36+
37+
#print 'STATUS SUMMARY:'
38+
#for k,v in summary.items():
39+
# print k, len(v)
40+
41+
print '\nCREATED:'
42+
print '\n'.join(['%s: %s'%(id, db.issue.get(id, 'title'))
43+
for id in created])
44+
45+
print '\nRESOLVED:'
46+
resolved_id = db.status.lookup('resolved')
47+
print '\n'.join(['%s: %s'%(id, db.issue.get(id, 'title'))
48+
for id in summary.get(resolved_id, [])])
49+
50+
print '\nTOP TEN MOST DISCUSSED:'
51+
messages.sort()
52+
messages.reverse()
53+
nmax = messages[0][0]
54+
fmt = '%%%dd - %%s: %%s'%(int(math.log(nmax, 10)) + 1)
55+
print '\n'.join([fmt%(num, id, db.issue.get(id, 'title'))
56+
for num, id in messages[:10]])
57+
58+
# vim: set filetype=python ts=4 sw=4 et si

0 commit comments

Comments
 (0)