* Fix chart sql,bug#34841.

This commit is contained in:
qixinzhi
2024-04-29 08:59:59 +00:00
parent ea07586a22
commit 9706d6570a
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -58,3 +58,5 @@ UPDATE `zt_metriclib` SET `metricCode` = 'sv_weekly_in_waterfall'
UPDATE `zt_metriclib` SET `metricCode` = 'cv_weekly_in_waterfall' WHERE `metricCode` = 'cv_in_waterfall';
UPDATE `zt_metric` SET `definition` = '复用:\r\n按项目统计的实际工期\r\n按项目统计的计划工期\r\n公式:\r\n按项目统计的工期偏差=按项目统计的实际工期-按项目统计的计划工期\r\n其中未开始项目工期偏差为0' WHERE `code` = 'variance_of_time_in_project';
UPDATE `zt_chart` SET `sql` = 'select\r\nyear,\r\ncount(a.id) as totalBugCount,\r\nsum(a.effectivebug) as effectiveBugCount,\r\nround(sum(a.effectivebug)/count(a.id) * 100, 2) effectiveBugRate\r\nfrom(\r\nselect \r\nleft(openedDate,4) year,\r\nid,\r\n(case when resolution in (\'fixed\',\'postponed\') or status=\'active\' then 1 else 0 end) effectivebug,\r\n(case when resolution=\'fixed\' then 1 else 0 end) fixedBug\r\nfrom zt_bug\r\nwhere zt_bug.deleted=\'0\'\r\n) a\r\ngroup by a.year\r\norder by a.year' WHERE `name` = '质量数据-有效Bug率年度趋势图';
+1 -1
View File
@@ -16641,7 +16641,7 @@ INSERT INTO `zt_chart`(`id`, `name`, `dimension`, `type`, `group`, `dataset`, `d
(10209, '质量数据-Bug密度', 3, 'waterpolo', '91', '0', '', '[{\"type\":\"waterpolo\",\"calc\":\"sum\",\"goal\":\"bugdensity\",\"conditions\":[{\"field\":\"havebug\",\"condition\":\"eq\",\"value\":\"havebug\"}]}]', '[]', 0, '{\"bugdensity\":{\"name\":\"bugdensity\",\"object\":\"bug\",\"field\":\"bugdensity\",\"type\":\"number\"},\"havebug\":{\"name\":\"havebug\",\"object\":\"bug\",\"field\":\"havebug\",\"type\":\"string\"}}', '{\"bugdensity\":{\"zh-cn\":\"Bug\\u5bc6\\u5ea6\",\"zh-tw\":\"\",\"en\":\"bugdensity\",\"de\":\"\",\"fr\":\"\"},\"havebug\":{\"zh-cn\":\"\\u662f\\u5426\\u6709Bug\",\"zh-tw\":\"\",\"en\":\"havebug\",\"de\":\"\",\"fr\":\"\"}}', 'SELECT ROUND(SUM(t3.bug)/SUM(t3.estimate), 4) AS bugdensity, \'havebug\' as havebug FROM (SELECT t1.product product, IFNULL(t1.estimate,0) estimate, IFNULL(t2.bug,0) bug FROM (SELECT product, ROUND(SUM(estimate),2) estimate FROM zt_story WHERE deleted=\'0\' AND (stage IN (\'developed\',\'testing\',\'verfied\',\'released\') OR (status=\'closed\' AND closedReason=\'done\')) GROUP BY product) t1 LEFT JOIN (SELECT product, COUNT(id) bug FROM zt_bug WHERE deleted=\'0\' GROUP BY product) t2 ON t1.product=t2.product) t3\nunion\nSELECT ROUND(1-SUM(t3.bug)/SUM(t3.estimate), 4) AS bugdensity, \'nobug\' as havebug FROM (SELECT t1.product product, IFNULL(t1.estimate,0) estimate, IFNULL(t2.bug,0) bug FROM (SELECT product, ROUND(SUM(estimate),2) estimate FROM zt_story WHERE deleted=\'0\' AND (stage IN (\'developed\',\'testing\',\'verfied\',\'released\') OR (status=\'closed\' AND closedReason=\'done\')) GROUP BY product) t1 LEFT JOIN (SELECT product, COUNT(id) bug FROM zt_bug WHERE deleted=\'0\' GROUP BY product) t2 ON t1.product=t2.product) t3', 'published', 0, '', 'system', '2022-12-07 14:59:41', 'admin', '2022-12-07 14:59:41', 0),
(10210, '质量数据-Bug修复率', 3, 'waterpolo', '91', '0', '', '[{\"type\":\"waterpolo\",\"calc\":\"sum\",\"goal\":\"fixpercent\",\"conditions\":[{\"field\":\"havebug\",\"condition\":\"eq\",\"value\":\"havebug\"}]}]', '[]', 0, '{\"fixpercent\":{\"name\":\"fixpercent\",\"object\":\"bug\",\"field\":\"fixpercent\",\"type\":\"number\"},\"havebug\":{\"name\":\"havebug\",\"object\":\"bug\",\"field\":\"havebug\",\"type\":\"string\"}}', '{\"fixpercent\":{\"zh-cn\":\"Bug\\u4fee\\u590d\\u7387\",\"zh-tw\":\"\",\"en\":\"fixpercent\",\"de\":\"\",\"fr\":\"\"},\"havebug\":{\"zh-cn\":\"\\u662f\\u5426\\u6709Bug\",\"zh-tw\":\"\",\"en\":\"havebug\",\"de\":\"\",\"fr\":\"\"}}', 'SELECT ROUND(SUM(CASE WHEN resolution=\'fixed\' THEN 1 ELSE 0 END)/COUNT(id),4) AS fixpercent, \'havebug\' as havebug FROM zt_bug WHERE deleted = \'0\' \nunion\nSELECT ROUND(1-SUM(CASE WHEN resolution=\'fixed\' THEN 1 ELSE 0 END)/COUNT(id),4) AS fixpercent, \'nobug\' as havebug FROM zt_bug WHERE deleted = \'0\'', 'published', 0, '', 'system', '2022-12-07 14:59:41', 'admin', '2022-12-07 14:59:41', 0),
(10211, '质量数据-Bug总数、有效Bug与解决Bug数近30天统计柱形图', 3, 'cluBarX', '91', '0', '', '[{\"type\":\"cluBarX\",\"xaxis\":[{\"field\":\"\\u65e5\\u671f\",\"name\":\"\\u65e5\\u671f\",\"group\":\"day\"}],\"yaxis\":[{\"field\":\"Bug\\u603b\\u6570\",\"name\":\"Bug\\u603b\\u6570\",\"valOrAgg\":\"count\"},{\"field\":\"\\u6709\\u6548Bug\",\"name\":\"\\u6709\\u6548Bug\",\"valOrAgg\":\"sum\"},{\"field\":\"\\u5df2\\u89e3\\u51b3Bug\",\"name\":\"\\u5df2\\u89e3\\u51b3Bug\",\"valOrAgg\":\"sum\"}]}]', '[]', 4, '{\"Bug\\u603b\\u6570\":{\"name\":\"Bug\\u603b\\u6570\",\"object\":\"bug\",\"field\":\"Bug\\u603b\\u6570\",\"type\":\"number\"},\"\\u6709\\u6548Bug\":{\"name\":\"\\u6709\\u6548Bug\",\"object\":\"bug\",\"field\":\"\\u6709\\u6548Bug\",\"type\":\"string\"},\"\\u5df2\\u89e3\\u51b3Bug\":{\"name\":\"\\u5df2\\u89e3\\u51b3Bug\",\"object\":\"bug\",\"field\":\"\\u5df2\\u89e3\\u51b3Bug\",\"type\":\"string\"},\"\\u65e5\\u671f\":{\"name\":\"\\u65e5\\u671f\",\"object\":\"bug\",\"field\":\"\\u65e5\\u671f\",\"type\":\"date\"}}', '', 'select \nid \"Bug总数\",\n(case when resolution in (\'fixed\',\'postponed\') or status=\'active\' then 1 else 0 end) \"有效Bug\",\n(case when resolution=\'fixed\' then 1 else 0 end) \"已解决Bug\",\nopenedDate \"日期\"\nfrom zt_bug\nwhere left(openedDate,10) > (select DATE_sub(MAX(NOW()), INTERVAL \'30\' DAY)) \nand left(openedDate,10) < NOW()\nand deleted=\'0\'', 'published', 1, '', 'system', '2023-04-06 12:51:56', 'admin', '2023-04-06 12:51:56', 0),
(10212, '质量数据-有效Bug率年度趋势图', 3, 'line', '91', '0', '', '[{\"type\":\"line\",\"xaxis\":[{\"field\":\"year\",\"name\":\"year\",\"group\":\"\"}],\"yaxis\":[{\"field\":\"effectiveBugRate\",\"name\":\"effectiveBugRate\",\"valOrAgg\":\"sum\"}]}]', '[{\"field\":\"year\",\"type\":\"select\",\"name\":\"\\u5e74\\u4efd\"}]', 4, '{\"year\":{\"name\":\"year\",\"object\":\"bug\",\"field\":\"year\",\"type\":\"string\"},\"totalBugCount\":{\"name\":\"totalBugCount\",\"object\":\"bug\",\"field\":\"totalBugCount\",\"type\":\"string\"},\"effectiveBugCount\":{\"name\":\"effectiveBugCount\",\"object\":\"bug\",\"field\":\"effectiveBugCount\",\"type\":\"number\"},\"effectiveBugRate\":{\"name\":\"effectiveBugRate\",\"object\":\"bug\",\"field\":\"effectiveBugRate\",\"type\":\"number\"}}', '{\"year\":{\"zh-cn\":\"\\u5e74\\u4efd\",\"zh-tw\":\"\",\"en\":\"Year\",\"de\":\"\",\"fr\":\"\"},\"totalBugCount\":{\"zh-cn\":\"Bug\\u603b\\u6570\",\"zh-tw\":\"\",\"en\":\"Total Bug Count\",\"de\":\"\",\"fr\":\"\"},\"effectiveBugCount\":{\"zh-cn\":\"\\u6709\\u6548Bug\\u6570\",\"zh-tw\":\"\",\"en\":\"Effective Bug Count\",\"de\":\"\",\"fr\":\"\"},\"effectiveBugRate\":{\"zh-cn\":\"\\u6709\\u6548Bug\\u7387\",\"zh-tw\":\"\",\"en\":\"Effective Bug Rate\",\"de\":\"\",\"fr\":\"\"}}', 'select\nyear,\ncount(a.id) as totalBugCount,\nsum(a.effectivebug) as effectiveBugCount,\nsum(a.effectivebug)/count(a.id) effectiveBugRate\nfrom(\nselect \nleft(openedDate,4) year,\nid,\n(case when resolution in (\'fixed\',\'postponed\') or status=\'active\' then 1 else 0 end) effectivebug,\n(case when resolution=\'fixed\' then 1 else 0 end) fixedBug\nfrom zt_bug\nwhere zt_bug.deleted=\'0\'\n) a\ngroup by a.year\norder by a.year', 'published', 0, '', 'system', '2023-04-06 13:00:04', 'admin', '2023-04-06 13:00:04', 0),
(10212, '质量数据-有效Bug率年度趋势图', 3, 'line', '91', '0', '', '[{\"type\":\"line\",\"xaxis\":[{\"field\":\"year\",\"name\":\"year\",\"group\":\"\"}],\"yaxis\":[{\"field\":\"effectiveBugRate\",\"name\":\"effectiveBugRate\",\"valOrAgg\":\"sum\"}]}]', '[{\"field\":\"year\",\"type\":\"select\",\"name\":\"\\u5e74\\u4efd\"}]', 4, '{\"year\":{\"name\":\"year\",\"object\":\"bug\",\"field\":\"year\",\"type\":\"string\"},\"totalBugCount\":{\"name\":\"totalBugCount\",\"object\":\"bug\",\"field\":\"totalBugCount\",\"type\":\"string\"},\"effectiveBugCount\":{\"name\":\"effectiveBugCount\",\"object\":\"bug\",\"field\":\"effectiveBugCount\",\"type\":\"number\"},\"effectiveBugRate\":{\"name\":\"effectiveBugRate\",\"object\":\"bug\",\"field\":\"effectiveBugRate\",\"type\":\"number\"}}', '{\"year\":{\"zh-cn\":\"\\u5e74\\u4efd\",\"zh-tw\":\"\",\"en\":\"Year\",\"de\":\"\",\"fr\":\"\"},\"totalBugCount\":{\"zh-cn\":\"Bug\\u603b\\u6570\",\"zh-tw\":\"\",\"en\":\"Total Bug Count\",\"de\":\"\",\"fr\":\"\"},\"effectiveBugCount\":{\"zh-cn\":\"\\u6709\\u6548Bug\\u6570\",\"zh-tw\":\"\",\"en\":\"Effective Bug Count\",\"de\":\"\",\"fr\":\"\"},\"effectiveBugRate\":{\"zh-cn\":\"\\u6709\\u6548Bug\\u7387\",\"zh-tw\":\"\",\"en\":\"Effective Bug Rate\",\"de\":\"\",\"fr\":\"\"}}', 'select\r\nyear,\r\ncount(a.id) as totalBugCount,\r\nsum(a.effectivebug) as effectiveBugCount,\r\nround(sum(a.effectivebug)/count(a.id) * 100, 2) effectiveBugRate\r\nfrom(\r\nselect \r\nleft(openedDate,4) year,\r\nid,\r\n(case when resolution in (\'fixed\',\'postponed\') or status=\'active\' then 1 else 0 end) effectivebug,\r\n(case when resolution=\'fixed\' then 1 else 0 end) fixedBug\r\nfrom zt_bug\r\nwhere zt_bug.deleted=\'0\'\r\n) a\r\ngroup by a.year\r\norder by a.year', 'published', 0, '', 'system', '2023-04-06 13:00:04', 'system', '2023-04-06 13:00:04', 0),
(10213, '质量数据-Bug密度年度趋势图', 3, 'line', '91', '0', '', '[{\"type\":\"line\",\"xaxis\":[{\"field\":\"year\",\"name\":\"year\",\"group\":\"\"}],\"yaxis\":[{\"field\":\"bugCount\",\"name\":\"Bug\\u6570\",\"valOrAgg\":\"sum\"}]}]', '[{\"field\":\"year\",\"type\":\"select\",\"name\":\"\\u5e74\\u4efd\"}]', 4, '{\"year\":{\"name\":\"year\",\"object\":\"story\",\"field\":\"year\",\"type\":\"string\"},\"createdBugs\":{\"name\":\"createdBugs\",\"object\":\"story\",\"field\":\"createdBugs\",\"type\":\"string\"},\"exfixedstoryestimate\":{\"name\":\"exfixedstoryestimate\",\"object\":\"story\",\"field\":\"exfixedstoryestimate\",\"type\":\"number\"},\"bugCount\":{\"name\":\"Bug\\u6570\",\"object\":\"story\",\"field\":\"bugCount\",\"type\":\"number\"}}', '{\"year\":{\"zh-cn\":\"\\u5e74\\u4efd\",\"zh-tw\":\"\",\"en\":\"Year\",\"de\":\"\",\"fr\":\"\"},\"createdBugs\":{\"zh-cn\":\"\\u4ea7\\u751fBug\",\"zh-tw\":\"\",\"en\":\"Created Bug\",\"de\":\"\",\"fr\":\"\"},\"exfixedstoryestimate\":{\"zh-cn\":\"\\u5b8c\\u6210\\u9700\\u6c42\\u6570\",\"zh-tw\":\"\",\"en\":\"Finished Story\",\"de\":\"\",\"fr\":\"\"},\"bugCount\":{\"zh-cn\":\"\\u5355\\u4f4d\\u5b8c\\u6210\\u9700\\u6c42\\u89c4\\u6a21\\u4ea7\\u751f\\u7684Bug\\u6570\",\"zh-tw\":\"\",\"en\":\"Bug Density\",\"de\":\"\",\"fr\":\"\"}}', 'select\nbug.year as year,\ncreatedBugs, \nexfixedstoryestimate,\nround(createdBugs/exfixedstoryestimate,2) as bugCount \nfrom\n(select \nleft(openedDate,4) year,\ncount(id) createdBugs\nfrom zt_bug\nwhere zt_bug.deleted=\'0\'\ngroup by year\n) bug \nleft join\n(select\nsum(estimate) exfixedstoryestimate,\nleft(closedDate,4) year\nfrom\nzt_story\nwhere zt_story.deleted=\'0\' and zt_story.status=\'closed\' and zt_story.closedReason=\'done\'\ngroup by year\n) story\non story.year=bug.year\norder by bug.year', 'published', 0, '', 'system', '2023-04-06 13:05:10', 'admin', '2023-04-06 13:05:10', 0),
(10214, '质量数据-Bug严重程度年度堆积柱状图', 3, 'stackedBar', '91', '0', '', '[{\"type\":\"stackedBar\",\"xaxis\":[{\"field\":\"\\u5e74\\u4efd\",\"name\":\"\\u5e74\\u4efd\",\"group\":\"\"}],\"yaxis\":[{\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a1\\u7ea7\\u7684Bug\",\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a1\\u7ea7\\u7684Bug\",\"valOrAgg\":\"sum\"},{\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a2\\u7ea7\\u7684Bug\",\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a2\\u7ea7\\u7684Bug\",\"valOrAgg\":\"sum\"},{\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4f4e\\u4e8e2\\u7ea7\\u7684Bug\",\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4f4e\\u4e8e2\\u7ea7\\u7684Bug\",\"valOrAgg\":\"sum\"}]}]', '[{\"field\":\"\\u5e74\\u4efd\",\"type\":\"select\",\"name\":\"\\u5e74\\u4efd\"}]', 4, '{\"\\u6240\\u6709Bug\\u6570\":{\"name\":\"\\u6240\\u6709Bug\\u6570\",\"object\":\"bug\",\"field\":\"\\u6240\\u6709Bug\\u6570\",\"type\":\"string\"},\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a1\\u7ea7\\u7684Bug\":{\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a1\\u7ea7\\u7684Bug\",\"object\":\"bug\",\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a1\\u7ea7\\u7684Bug\",\"type\":\"number\"},\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a2\\u7ea7\\u7684Bug\":{\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a2\\u7ea7\\u7684Bug\",\"object\":\"bug\",\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4e3a2\\u7ea7\\u7684Bug\",\"type\":\"number\"},\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4f4e\\u4e8e2\\u7ea7\\u7684Bug\":{\"name\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4f4e\\u4e8e2\\u7ea7\\u7684Bug\",\"object\":\"bug\",\"field\":\"\\u4e25\\u91cd\\u7a0b\\u5ea6\\u4f4e\\u4e8e2\\u7ea7\\u7684Bug\",\"type\":\"number\"},\"\\u5e74\\u4efd\":{\"name\":\"\\u5e74\\u4efd\",\"object\":\"bug\",\"field\":\"\\u5e74\\u4efd\",\"type\":\"string\"}}', '', 'select\ncount(id) \"所有Bug数\",\nsum(case when severity=1 then 1 else 0 end) \"严重程度为1级的Bug\",\nsum(case when severity=2 then 1 else 0 end) \"严重程度为2级的Bug\",\nsum(case when severity not in (1,2) then 1 else 0 end) \"严重程度低于2级的Bug\",\nleft(openedDate,4) \"年份\"\nfrom\nzt_bug\nwhere deleted=\'0\'\ngroup by left(openedDate,4)\norder by left(openedDate,4)', 'published', 1, '', 'system', '2023-04-06 13:12:34', 'admin', '2023-04-06 13:12:34', 0),
(10215, '质量数据-产品用例数量统计条形图', 3, 'cluBarY', '91', '0', '', '[{\"type\":\"cluBarY\",\"xaxis\":[{\"field\":\"name\",\"name\":\"name\",\"group\":\"\"}],\"yaxis\":[{\"field\":\"count\",\"name\":\"count\",\"valOrAgg\":\"sum\"}]}]', '[{\"field\":\"name\",\"type\":\"select\",\"name\":\"\\u4ea7\\u54c1\"}]', 4, '{\"name\":{\"name\":\"name\",\"object\":\"product\",\"field\":\"name\",\"type\":\"string\"},\"count\":{\"name\":\"count\",\"object\":\"testcase\",\"field\":\"id\",\"type\":\"string\"}}', '{\"name\":{\"zh-cn\":\"\\u4ea7\\u54c1\\u540d\\u79f0\",\"zh-tw\":\"\",\"en\":\"Product\",\"de\":\"\",\"fr\":\"\"},\"count\":{\"zh-cn\":\"\\u7528\\u4f8b\\u8ba1\\u6570\",\"zh-tw\":\"\",\"en\":\"Case Count\",\"de\":\"\",\"fr\":\"\"}}', 'select \nt1.name,\nifnull(t2.cases,0) as count\nfrom\nzt_product t1\nleft join\n(\nselect\nproduct,\ncount(id) cases \nfrom\nzt_case\nwhere deleted=\'0\'\ngroup by product )\nt2 on t1.id=t2.product', 'published', 0, '', 'system', '2023-04-06 13:33:48', 'admin', '2023-04-06 13:33:48', 0),