基于jira的缺陷自动化报表分析 (五)按项目统计缺陷情况

一、创建项目缺陷统计表

CREATE TABLE `project_issues` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project` varchar(20) DEFAULT NULL,
  `amount_find` int(11) DEFAULT NULL COMMENT '当天发现',
  `amount_repair` int(11) DEFAULT NULL COMMENT '当天修复',
  `amount_lave` int(11) DEFAULT NULL COMMENT '剩余未关闭',
  `date` varchar(20) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=922 DEFAULT CHARSET=utf8mb4;

 

二、组装项目缺陷统计JQL

def ana_project(project_name):
    # 当天发现数量
    jql_finds = """
    project="{}" AND issuetype = 故障 AND created >= {} AND created < {}
    """.format(project_name, yesterday, today)
    amount_finds = Ana_jira(test_jira, jql_finds).req_jira()
    # 当天修复数量
    jql_repairs = """project = {} AND issuetype = 故障 AND 修复日期 = {}""".format(project_name, yesterday)
    amount_repairs = Ana_jira(test_jira, jql_repairs).req_jira()
    # 未关闭缺陷总数
    lave_jql = """
    project = {} AND status in (Open, "In Progress", Reopened, 待审查, 待验证, refused, 无法复现, 延后处理) 
    AND resolution = Unresolved
    """.format(project_name)
    amount_lave = Ana_jira(test_jira, lave_jql).req_jira()
    return amount_finds, amount_repairs, amount_lave

 

三、将统计结果插入到数据库

def project_insert(project_name):
    amount_finds, amount_repairs, amount_lave = ana_project(project_name)
    sql = """
    INSERT INTO `project_issues` (`project`, `amount_find`, `amount_repair`, `amount_lave`, `date`, `create_time`)
     VALUES ('{}', {}, {}, {}, '{}', '{}');
    """.format(project_name, amount_finds, amount_repairs, amount_lave, yesterday, datetime.now())
    MysqlUntil().mysql_insert(sql)

 

四、执行统计,查看结果

project_insert(project_name)

基于jira的缺陷自动化报表分析 (五)按项目统计缺陷情况_第1张图片

你可能感兴趣的:(jira,缺陷自动化分析,PYTHON,python,mysql,数据分析)