基于禅道数据库对bug进行不同维度统计

工作中经常需要在周报、月报、年报对禅道bug数据进行不同维度统计导出,以下是我常用的统计sql

 

1、统计2022年每个月bug数(deleted='0'是查询未删除的bug)

select  DATE_FORMAT(a.openedDate,'%Y-%m') as '月份',count(DATE_FORMAT(a.openedDate,'%Y-%m')) 'bug数量'  from zt_bug a 
where a.deleted='0' and a.openedDate>'2022-01-01' and a.openedDate<'2023-01-01' GROUP BY DATE_FORMAT(a.openedDate,'%Y-%m')

2、统计2022年测试人员每个月创建bug数量

select c.realname '创建人', DATE_FORMAT(a.openedDate,'%Y-%m') as '月份',count(c.realname) 'bug数量'  from zt_bug a 
left join zt_user c on a.openedBy=c.account 
where a.deleted='0' and   a.openedDate>'2022-01-01'  and a.openedDate<'2023-01-01'  GROUP BY c.realname,DATE_FORMAT(a.openedDate,'%Y-%m')

 

  3、统计2022年开发人员每个月被指派bug数量(有效bug排除5个resolution解决方案:external外部原因,bydesign设计如此,willnotfix不予解决,notrepro无法重现,duplicate重复bug)

select IF(a.resolution !='',f.realname,e.realname) '解决人',DATE_FORMAT(a.openedDate,'%Y-%m') as '月份',count(1) 'bug数量' from zt_bug a 
left join zt_user f on a.resolvedBy=f.account 
left join zt_user e on a.assignedTo=e.account   
where a.deleted='0' and a.openedDate>'2022-01-01' and a.openedDate<'2023-02-16' and a.resolution not in ('external','bydesign','willnotfix','notrepro','duplicate')
GROUP BY IF(a.resolution !='',f.realname,e.realname),DATE_FORMAT(a.openedDate,'%Y-%m')

 

 4、统计某段时间内的bug详细数据,将代码转化为中文、将用户名转化成中文

select a.id 'BugID',b.name '产品',
case a.type when 'designdefect' then '设计缺陷' when 'codeerror' then '代码错误' when 'standard' then '标准规范' when 'others' then '其它' when 'config' then '配置相关' 
when 'interface' then '界面优化' when 'install' then '安装部署' end 'Bug类型', a.title 'Bug标题',a.severity '级别',a.pri '优先级', case a.status when 'closed' then '已关闭' when 'resolved' then '已解决' when 'active' then '激活' end '状态', c.realname '创建人',a.openedDate'创建时间',i.name '项目',d.name '版本',e.realname '指派人',g.name '组别',f.realname '解决人',h.name '组别(已解决)',a.activatedCount '激活次数',a.resolvedDate '解决时间', case a.resolution when 'fixed' then '已解决' when 'external' then '外部原因' when 'bydesign' then '设计如此' when 'willnotfix' then '不予解决' when 'notrepro' then '无法重现'
when 'postponed' then '延期处理' when 'duplicate' then '重复bug' end as '解决方案' from zt_bug a left join zt_product b on b.id=a.product left join zt_user c on a.openedBy=c.account left join zt_user f on a.resolvedBy=f.account left join zt_user e on a.assignedTo=e.account left join zt_build d on d.id=a.openedBuild left join zt_dept h on f.dept=h.id left join zt_dept g on e.dept=g.id left join zt_project i on d.project=i.id -- where DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= date(a.openedDate) and a.deleted='0' where a.deleted='0' and a.openedDate>'2023-01-01' and a.openedDate<'2023-02-01'

 

  5、统计某段时间内各项目bug情况:产品+项目名+版本名+数量

select b.name '产品',i.name '项目',d.name '版本',count(d.name) as "bug总数量" from zt_bug a 
left join zt_product b on b.id=a.product
left join zt_build d on d.id=a.openedBuild
left join zt_project i on d.project=i.id
where a.openedDate>'2022-10-01' and a.openedDate<'2022-11-01' and a.deleted='0' and d.name is not null
group by b.name,i.name,d.name ORDER BY count(d.name) desc

 

posted @ 2023-02-15 11:30  dabeen  阅读(285)  评论(0编辑  收藏  举报