接上文 基于jira的缺陷自动化报表分析 (七)matplotlib 饼图:缺陷严重性分布 继续绘制缺陷类型分布饼图
一、统计数据
1、准备统计缺陷类型SQL
2、查询缺陷类型分布数据,绘制饼状图
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('项目{}最近{}周缺陷类型占比分布图统计完成'.format(self.project_name, self.weeks)) else: print('项目{}最近{}周未验证缺陷,无法统计缺陷类型占比分布图'.format(self.project_name, self.weeks))
二、执行统计,查看结果
c = Cake(project_name, test_jira, first_day, last_day, types, weeks, project_report_path) c.cake_issue_type() # (项目)缺陷类型分布