From: Marlon v. d. B. <mar...@mo...> - 2004-11-05 10:20:57
|
On Friday, November 05, 2004 9:36 AM, Shah, Bijal wrote: > I have come up with an approach, but it means I need to know the names > of the retired users. Not a problem since I retired them, but equally > possible to do by looking at export data as that contains a full list. > I've written a bit of python to do the job, but its slow and it needs > testing now. Why not get the list of all issues. Per issue get the nosy list. Check all names on that list. And update the issue with only those names on the nosy list that do exist. In simple code this would be something like: for issue_id in db.issue.list(): nosy = db.issue.get(issue_id, 'nosy') new_nosy = [] for user_id in nosy: try: db.user.get(user_id, 'username') except: # not in db or retired pass else: new_nosy.append(user_id) if len(new_nosy) != len(nosy): db.user.set(user_id, nosy=new_nosy) db.commit() What's left is to first open the db and to close it after the commit. To prevent these problems in the feature, use a detector (reactor) for the user->retire event. It will be executed after the user is retired. You can use it to remove that user (the id of the retired user is passed to the detector) from all nosy lists. If I'm correct issues = db.issue.filter(None, { 'nosy': retired_user_id }) will give you a list with issues that have this user in the nosy list. Regards, Marlon |