怎样计算Apache Jira中的所有项目的issue个数

Apache的JIRA是Apache的多个项目的Issue Tracking System:https://issues.apache.org/jira

不过怎么统计这些项目中都各自有多少issue呢,相信这个问题是很多做Mining Software Repository的朋友们都会关心的。我试着用jira-python统计了一下,虽然很不优雅,但总算是可以获取到。jira-python的doc在:https://jira.readthedocs.io/en/latest/

下面是实现代码,很简单。虽然很不低碳环保,但总算是能实现功能:

from jira import JIRA

record_file=open('Jira_count_results.csv','w')

options={'server': 'https://issues.apache.org/jira'}
jira = JIRA(options)

projects = jira.projects()
print(len(projects))

for each_project in projects:
    start_num=0
    total_issue_number=0
    while(True):
        issues=jira.search_issues(('project = "%s" ')%(each_project.key), startAt=start_num, maxResults=-1)
        total_issue_number=total_issue_number+len(issues)
        if(len(issues)==0):
            break
        start_num=start_num+1000
    print(each_project.key)
    print(total_issue_number)
    record_file.write(each_project.key+','+str(total_issue_number)+'\n')
    record_file.flush()

相信大家一看就懂。就简单记录这么多。

你可能感兴趣的:(科研工具,Python技巧)