On Tue, 2012-05-22 at 00:04 +0200, Pierre-Yves Chibon wrote: > On Mon, 2012-05-21 at 10:38 -0600, Kevin Fenzi wrote: > > After the bugzilla upgrade this weekend a few things we run related to > > bugzilla are having issues: > > > > 1) on fas01, the script that sets fedorabugs and fedora_contrib on > > users in those fedora groups isn't working. > > > > 2) on bapp01, the cron job that gathers easyfix bugzilla bugs is not > > working. > > > > 3) pkgdb, which runs on app servers isnt' able to handle adding new > > packages. (we aren't sure what the error here is, but is likely bz > > related). > > 4) the review-stats script is having problems. > I spent some time on this and I have a patch that runs fine on my > machine against the official bugzilla and with the 'new' release of > python-bugzilla. > It is a little more heavy than the previous patches: > http://fpaste.org/dwwg/ Actually, there was a typo left in the first version, so there is (attached) a revised version. The difference: - querydata['product'] = ['Fedora EPEL'] + querydata['product'] = ['Fedora'] Fedora EPEL being used for testing as Fedora seems to always return a ProxyError. Pierre
From 10a786ffc405a9c283e79db4283f88cba2a6404f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon <pingou@xxxxxxxxxxxx> Date: Mon, 21 May 2012 21:01:29 +0200 Subject: [PATCH] Fix the review-stats script to work with the new bugzilla Thanks to tibbs and tflink for the hand Thanks bugzilla for so many hours of fun!! For some reasons the `last_change_time` field seems to be reset as soon as the object is touched, so I went around that by keeping it in the bugdata dictionary but maybe we'll find a better way to do this in the future. --- scripts/review-stats/review-stats.py | 67 +++++++++++++++++++++------------- 1 files changed, 41 insertions(+), 26 deletions(-) diff --git a/scripts/review-stats/review-stats.py b/scripts/review-stats/review-stats.py index 87a891b..0afe64b 100755 --- a/scripts/review-stats/review-stats.py +++ b/scripts/review-stats/review-stats.py @@ -99,8 +99,8 @@ def yrmonth(str): '''Turn a bugzilla date into Month YYYY string.''' m = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] - year = str.split('-')[0] - month = int(str.split('-')[1])-1 + year = str.split('.')[0] + month = int(str.split('.')[1])-1 return m[month] + ' ' + year def seq_max_split(seq, max_entries): @@ -125,23 +125,31 @@ def run_query(bz): querydata['column_list'] = ['opendate', 'changeddate', 'bug_severity', 'alias', 'assigned_to', 'reporter', 'bug_status', 'resolution', - 'component', 'blockedby', 'dependson', 'short_desc', + 'component', 'blocks', 'dependson', 'short_desc', 'status_whiteboard', 'flag_types'] querydata['product'] = ['Fedora'] querydata['component'] = ['Package Review'] + querydata['query_format'] = ['advanced'] + querydata['bug_status'] = ['NEW', 'ASSIGNED'] # Look up tickets with no flag set - querydata['field0-0-0'] = 'flagtypes.name' - querydata['type0-0-0'] = 'notregexp' - querydata['value0-0-0'] = 'fedora-review[-+?]' + querydata['f1'] = 'flagtypes.name' + querydata['o1'] = 'notregexp' + querydata['v1'] = 'fedora-review[-+?]' bugs = filter(lambda b: str(b.bug_id) not in trackers, bz.query(querydata)) + # For some reasons the `last_change_time` field seems to be reset as + # soon as the object is touched, so I went around that by keeping it + # in the bugdata dictionary but maybe we'll find a better way to do + # this in the future. for bug in bugs: + last_change_time = bug.last_change_time bugdata[bug.bug_id] = {} bugdata[bug.bug_id]['hidden'] = 0 - bugdata[bug.bug_id]['blockedby'] = set(str(bug.blockedby).split(', '))-set(['']) - bugdata[bug.bug_id]['depends'] = set(str(bug.dependson).split(', '))-set(['']) + bugdata[bug.bug_id]['blocks'] = set(bug.blocks) + bugdata[bug.bug_id]['depends'] = set(bug.dependson) bugdata[bug.bug_id]['reviewflag'] = ' ' + bugdata[bug.bug_id]['last_change_time'] = last_change_time # Keep track of dependencies in unflagged tickets alldeps |= bugdata[bug.bug_id]['depends'] @@ -160,21 +168,22 @@ def run_query(bz): or string.lower(bug.status_whiteboard).find('buildfails') >= 0 or string.lower(bug.status_whiteboard).find('stalledsubmitter') >= 0 or string.lower(bug.status_whiteboard).find('awaitingsubmitter') >= 0 - or BUNDLED in bugdata[bug.bug_id]['blockedby'] - or LEGAL in bugdata[bug.bug_id]['blockedby'] + or BUNDLED in bugdata[bug.bug_id]['blocks'] + or LEGAL in bugdata[bug.bug_id]['blocks'] or filter(opendep, bugdata[bug.bug_id]['depends']))): bugdata[bug.bug_id]['hidden'] = 1 # Now process the other three flags; not much special processing for them - querydata['type0-0-0'] = 'equals' + querydata['o1'] = 'equals' # for i in ['-', '+', '?']: for i in ['-', '?']: - querydata['value0-0-0'] = 'fedora-review' + i + querydata['v1'] = 'fedora-review' + i b1 = bz.query(querydata) for bug in b1: + b1.last_change_time = datetime.datetime.strptime(b1.last_change_time.value, "%Y%m%dT%H:%M:%S") bugdata[bug.bug_id] = {} bugdata[bug.bug_id]['hidden'] = 0 - bugdata[bug.bug_id]['blockedby'] = [] + bugdata[bug.bug_id]['blocks'] = [] bugdata[bug.bug_id]['depends'] = [] bugdata[bug.bug_id]['reviewflag'] = i bugs += b1 @@ -225,7 +234,7 @@ def select_merge(bug, bugd): def select_needsponsor(bug, bugd): if (bugd['reviewflag'] == ' ' - and NEEDSPONSOR in bugd['blockedby'] + and NEEDSPONSOR in bugd['blocks'] and bug.bug_status != 'CLOSED' and nobody(bug.assigned_to) == '(Nobody)'): return 1 @@ -244,12 +253,13 @@ def select_new(bug, bugd): # The data from a standard row in a bug list -def std_row(bug, rowclass): +def std_row(bug, rowclass, last_change_time): return {'id': bug.bug_id, 'alias': to_unicode(bug.alias), 'assignee': nobody(to_unicode(bug.assigned_to)), 'class': rowclass, - 'lastchange': bug.changeddate, + 'lastchange': datetime.datetime.strptime( + last_change_time.value, "%Y%m%dT%H:%M:%S"), 'status': bug.bug_status, 'summary': to_unicode(bug.short_desc), } @@ -264,12 +274,13 @@ def report_hidden(bugs, bugdata, loader, tmpdir, subs): for i in bugs: if select_hidden(i, bugdata[i.bug_id]): rowclass = 'bz_row_even' - if NEEDSPONSOR in bugdata[i.bug_id]['blockedby']: + if NEEDSPONSOR in bugdata[i.bug_id]['blocks']: rowclass = 'bz_state_NEEDSPONSOR' elif data['count'] % 2 == 1: rowclass = 'bz_row_odd' - data['bugs'].append(std_row(i, rowclass)) + data['bugs'].append(std_row(i, rowclass, + bugdata[i.bug_id]['last_change_time'])) data['count'] +=1 write_html(loader, 'plain.html', data, tmpdir, 'HIDDEN.html') @@ -290,7 +301,8 @@ def report_merge(bugs, bugdata, loader, tmpdir, subs): if data['count'] % 2 == 1: rowclass = 'bz_row_odd' - data['bugs'].append(std_row(i, rowclass)) + data['bugs'].append(std_row(i, rowclass, + bugdata[i.bug_id]['last_change_time'])) data['count'] +=1 write_html(loader, 'plain.html', data, tmpdir, 'MERGE.html') @@ -321,7 +333,8 @@ def report_needsponsor(bugs, bugdata, loader, tmpdir, subs): curreporter = reporter(i) curcount = 0 - data['months'][-1]['bugs'].append(std_row(i, rowclass)) + data['months'][-1]['bugs'].append(std_row(i, rowclass, + bugdata[i.bug_id]['last_change_time'])) data['count'] +=1 curcount +=1 @@ -340,21 +353,23 @@ def report_new(bugs, bugdata, loader, tmpdir, subs): for i in bugs: if select_new(i, bugdata[i.bug_id]): rowclass = 'bz_row_even' - if NEEDSPONSOR in bugdata[i.bug_id]['blockedby']: + if NEEDSPONSOR in bugdata[i.bug_id]['blocks']: rowclass = 'bz_state_NEEDSPONSOR' - elif FEATURE in bugdata[i.bug_id]['blockedby']: + elif FEATURE in bugdata[i.bug_id]['blocks']: rowclass = 'bz_state_FEATURE' elif data['count'] % 2 == 1: rowclass = 'bz_row_odd' - if curmonth != yrmonth(i.opendate): + if curmonth != yrmonth(i.creation_ts): if curcount > 0: data['months'][-1]['month'] += (" (%d)" % curcount) - data['months'].append({'month': yrmonth(i.opendate), 'bugs': []}) - curmonth = yrmonth(i.opendate) + data['months'].append({'month': yrmonth(i.creation_ts), 'bugs': []}) + curmonth = yrmonth(i.creation_ts) curcount = 0 - data['months'][-1]['bugs'].append(std_row(i, rowclass)) + i.last_change_time = datetime.datetime.strptime(i.last_change_time.value, "%Y%m%dT%H:%M:%S") + data['months'][-1]['bugs'].append(std_row(i, rowclass, + bugdata[i.bug_id]['last_change_time'])) data['count'] +=1 curcount +=1 -- 1.7.1
_______________________________________________ infrastructure mailing list infrastructure@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/infrastructure