This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to generate stats based on the activity on RDO Bugzilla | |
# during Bug Triage Day | |
# | |
# Autho: Chandan Kumar <chkumar246@gmail.com> | |
# | |
# How to run this script | |
# python bztraigeday_stats.py | |
import bugzilla | |
BZ_URL = "https://bugzilla.redhat.com" | |
PRODUCT = "RDO" | |
TRIAGE_DATES = [20160518] | |
def get_affected_bugs(): | |
""" | |
Returns a list of affected bugs in between triage dates | |
""" | |
bz = bugzilla.Bugzilla(url=BZ_URL) | |
bugs = bz.query(bz.build_query(product=PRODUCT)) | |
affected_bzs = [bug for bug in bugs if int(bug.last_change_time.value.split(':')[0].split('T')[0]) >= TRIAGE_DATES[0]] | |
print "%d Bugs affected on Bug Triage Day." % len(affected_bzs) | |
return affected_bzs | |
def get_closed_bugs(affected_bzs): | |
""" | |
Get a list of closed Bugs on Bug Triage Day | |
""" | |
closed_bzs = [bug for bug in affected_bzs if bug.status == 'CLOSED'] | |
print "%d Bugs closed on Bug Triage Day" % len(closed_bzs) | |
return closed_bzs | |
def get_updators_on_bugtraiged(bug): | |
""" | |
Get updator names who updated a particular bug on bug traige day | |
""" | |
email = [] | |
history = bug.get_history()['bugs'][-1]['history'] | |
for i in history: | |
if int(i['when'].value.split(':')[0].split('T')[0]) >= 20160518: | |
email.append(i['who']) | |
return email | |
def generate_stats(): | |
""" | |
Return emails who had participated in Bug triage Day | |
""" | |
print "Have Patience! it will take some time..." | |
bugs = get_affected_bugs() | |
closed_bugs = get_closed_bugs(bugs) | |
changed_bugs = list(set(bugs)-set(closed_bugs)) | |
print "%d Bugs changed on Bug Triage Day" % len(changed_bugs) | |
activity = {} | |
for bug in changed_bugs: | |
activity.update({bug.weburl: get_updators_on_bugtraiged(bug)}) | |
# print bug.weburl + " " + "Done" | |
emails = [] | |
for email in activity.values(): | |
emails.extend(email) | |
return list(set(emails)) | |
if __name__ == '__main__': | |
contributors = generate_stats() | |
print "%d people participated in RDO Bug Traige Day.\n" % len(contributors) | |
print '\n'.join(contributors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment