Continued from the above Jira-based defect automated report analysis (7) matplotlib pie chart: Defect severity distribution continues to draw defect type distribution pie chart
1. Statistics
1. Prepare statistical defect type SQL
2. Query the distribution data of defect types and draw a pie chart
def cake_issue_type(self): """ :return: """ sql = """ SELECT issue_type, COUNT(id) AS counts FROM `jira_issues` WHERE project = '{}' AND issuetype = '故障' GROUP BY issue_type; """.format(self.project_name) datas = MysqlUntil().mysql_select(sql) # 开发人员以及各严重等级BUG数量 issue_type, counts = [], [] for data in datas: issue_type.append(data['issue_type']) counts.append(int(data['counts'])) if issue_type: Draw(self.report_path).drawing_cake(counts, issue_type, self.project_name, 'Issues Type Distribution (ALL CYCLE)') print('Project {}Recent {} week defect type distribution graph statistics completed'.format(self .project_name, self.weeks)) else: print('Project {} has not verified defects in recent {} weeks, and cannot calculate the distribution of defect types'.format(self.project_name, self.weeks))
2. Perform statistics and view results
c = Cake(project_name, test_jira, first_day, last_day, types, weeks, project_report_path) c.cake_issue_type() # (project) defect type distribution