1- #! /usr/bin/env python
1+ #! /usr/bin/env python2.2
22# Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/)
33#
44# Permission is hereby granted, free of charge, to any person obtaining a copy
1919# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020# SOFTWARE.
2121
22- # $Id: roundup-reminder,v 1.6 2003-04-24 07:19:59 richard Exp $
22+ # $Id: roundup-reminder,v 1.6.2.1 2004-02-11 00:02:53 richard Exp $
2323
2424'''
2525Simple script that emails all users of a tracker with the issues that
2626are currently assigned to them.
2727
2828TODO: introduce some structure ;)
2929TODO: possibly make this more general and configurable...
30-
31- Note: The instance that this script was designed for has a modified schema!
32- You will want to modify this script to customise it for your own schema!
3330'''
3431
3532import sys , cStringIO , MimeWriter , smtplib
@@ -45,6 +42,18 @@ db = instance.open('admin')
4542
4643resolved_id = db .status .lookup ('resolved' )
4744
45+ def listCompare (x , y ):
46+ "compare two tuples such that order is positive on [0] and negative on [1]"
47+ if x [0 ] < y [0 ]:
48+ return - 1
49+ if x [0 ] > y [0 ]:
50+ return 1
51+ if x [1 ] > y [1 ]:
52+ return - 1
53+ if x [1 ] < y [1 ]:
54+ return 1
55+ return 0
56+
4857# loop through all the users
4958for user_id in db .user .list ():
5059 # make sure we care aboue this user
@@ -58,16 +67,14 @@ for user_id in db.user.list():
5867 # extract this user's issues
5968 l = []
6069 for issue_id in db .issue .find (assignedto = user_id ):
61- if db .issue .get (issue_id , 'status' ) == resolved_id : continue
62- timeliness_id = db .issue .get (issue_id , 'timeliness' )
63- if timeliness_id :
64- timeliness = db .timeliness .get (timeliness_id , 'name' )
65- else :
66- timeliness = '~~~'
67- l .append ((timeliness , db .issue .get (issue_id , 'creation' ), issue_id ))
70+ if db .issue .get (issue_id , 'status' ) == resolved_id :
71+ continue
72+ order = db .priority .get (db .issue .get (issue_id , 'priority' ), 'order' )
73+ l .append ((order , db .issue .get (issue_id , 'activity' ),
74+ db .issue .get (issue_id , 'creation' ), issue_id ))
6875
6976 # sort the issues by timeliness and creation date
70- l .sort ()
77+ l .sort (listCompare )
7178 if not l :
7279 continue
7380
@@ -92,17 +99,22 @@ for user_id in db.user.list():
9299 print >> body , 'Created ID Urgency Title'
93100 print >> body , '=' * 75
94101 # '2 months 213 immediate cc_daemon barfage
95- for timeliness , creation_date , issue_id in l :
102+ old_priority = None
103+ for priority_order , activity_date , creation_date , issue_id in l :
104+ priority = db .issue .get (issue_id , 'priority' )
105+ if (priority != old_priority ):
106+ old_priority = priority
107+ print >> body , ' ' , db .priority .get (priority ,'name' )
96108 # pretty creation
97109 creation = (date .Date ('.' ) - creation_date ).pretty ()
98110 if creation is None :
99111 creation = creation_date .pretty ()
100-
101- if not timeliness : timeliness = ''
112+ activity = (date .Date ('.' ) - activity_date ).pretty ()
102113 title = db .issue .get (issue_id , 'title' )
103- if len (title ) > 52 : title = title [:48 ] + ' ...'
104- print >> body , '%-11s %-4s %-9s %-52s' % (creation , issue_id ,
105- timeliness , title )
114+ if len (title ) > 42 :
115+ title = title [:38 ] + ' ...'
116+ print >> body , '%-11s %-4s %-9s %-42s' % (creation , issue_id ,
117+ activity , title )
106118
107119 # some help to finish off
108120 print >> body , '''
@@ -125,19 +137,23 @@ and click on "My Issues". Do NOT respond to this message.
125137 'whenever' : ' bgcolor="#ffffff"' ,
126138 }
127139 print >> body , '''<table border>
128- <tr><th>Created</th> <th>ID</th> <th>Urgency </th> <th>Title</th></tr>
140+ <tr><th>Created</th> <th>ID</th> <th>Activity </th> <th>Title</th></tr>
129141'''
130- for timeliness , creation_date , issue_id in l :
142+ old_priority = None
143+ for priority_order , activity_date , creation_date , issue_id in l :
144+ priority = db .issue .get (issue_id ,'priority' )
145+ if (priority != old_priority ):
146+ old_priority = priority
147+ print >> body , '<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>' % db .priority .get (priority ,'name' )
131148 creation = (date .Date ('.' ) - creation_date ).pretty ()
132149 if creation is None :
133150 creation = creation_date .pretty ()
134- if not timeliness_id : timeliness_id = ' '
135151 title = db .issue .get (issue_id , 'title' )
136152 issue_id = '<a href="%sissue%s">%s</a>' % (db .config .TRACKER_WEB ,
137153 issue_id , issue_id )
138- colour = colours . get ( timeliness , '' )
139- print >> body , '''<tr%s ><td>%s</td><td>%s</td><td>%s</td>
140- <td>%s</td></tr>''' % (colour , creation , issue_id , timeliness , title )
154+ activity = ( date . Date ( '.' ) - activity_date ). pretty ( )
155+ print >> body , '''<tr><td>%s</td><td>%s</td><td>%s</td>
156+ <td>%s</td></tr>''' % (creation , issue_id , activity , title )
141157 print >> body , '</table>'
142158
143159 print >> body , '''<p>To view or respond to any of the issues listed
0 commit comments