diff --git a/module/bi/config/metrics.php b/module/bi/config/metrics.php index 468f8582b0..9caa08f3c8 100644 --- a/module/bi/config/metrics.php +++ b/module/bi/config/metrics.php @@ -4369,6 +4369,20 @@ $config->bi->builtin->metrics[] = array 'definition' => "截止到执行开始当天的23:59分的研发需求个数求和,过滤已删除的研发需求\n过滤已删除的执行\n过滤已删除的项目\n过滤已删除的产品\n" ); +$config->bi->builtin->metrics[] = array +( + 'name' => '按执行统计的截止执行开始当天的研发需求规模数', + 'alias' => '截止执行开始当天的研发需求规模数', + 'code' => 'scale_of_story_in_execution_when_starting', + 'purpose' => 'scale', + 'scope' => 'execution', + 'object' => 'story', + 'unit' => 'hour', + 'dateType' => 'nodate', + 'desc' => '按执行统计的截止执行开始当天的研发需求规模数表示执行开始时已关联进执行的研发需求的规模数。该度量项反映了本期执行计划完成的需求规模,可以用于评估执行团队的工作负载。', + 'definition' => "截止到执行开始当天的23:59分的研发需求规模数求和,过滤已删除的研发需求\n过滤已删除的执行\n过滤已删除的项目\n过滤已删除的产品\n" +); + $config->bi->builtin->metrics[] = array ( 'name' => '按执行统计的来源Bug的任务消耗工时占比', diff --git a/module/metric/calc/execution/scale/scale_of_story_in_execution_when_starting.php b/module/metric/calc/execution/scale/scale_of_story_in_execution_when_starting.php new file mode 100644 index 0000000000..8c41ad6035 --- /dev/null +++ b/module/metric/calc/execution/scale/scale_of_story_in_execution_when_starting.php @@ -0,0 +1,65 @@ + + * @package + * @uses func + * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) + * @Link https://www.zentao.net + */ +class scale_of_story_in_execution_when_starting extends baseCalc +{ + public $dataset = 'getExecutionDevStories'; + + public $fieldList = array('t1.id as execution', 't1.realBegan', 't3.story', 't4.estimate', 't6.action', 't6.id as actionID', 't6.date as actionDate'); + + public $result = array(); + + public $storyInfo = array(); + /* e.g $storyInfo[3] = array('link' => 1, 'unlink' => 1, execution => 3); */ + + public function calculate($row) + { + // 关联、取消关联的时间是否小于等于项目的开始时间 + $actionDate = !helper::isZeroDate($row->actionDate) ? substr($row->actionDate, 0, 10) : null; + $realBegan = !helper::isZeroDate($row->realBegan) ? $row->realBegan : null; + + $condition1 = ($actionDate && $realBegan && $actionDate <= $realBegan); + if($condition1) + { + if(!isset($this->storyInfo[$row->story])) $this->storyInfo[$row->story] = array('link' => 0, 'unlink' => 0, 'estimate' => $row->estimate, 'execution' => $row->execution); + if($row->action == 'linked2execution') $this->storyInfo[$row->story]['link'] += 1; + if($row->action == 'unlinked2execution') $this->storyInfo[$row->story]['unlink'] += 1; + } + } + + public function getResult($options = array()) + { + foreach($this->storyInfo as $storyID => $storyInfo) + { + $link = $storyInfo['link']; + $unlink = $storyInfo['unlink']; + $estimate = $storyInfo['estimate']; + $execution = $storyInfo['execution']; + + if($link - $unlink <= 0) continue; + + if(!isset($this->result[$execution])) $this->result[$execution] = 0; + $this->result[$execution] += $estimate; + } + + $records = $this->getRecords(array('execution', 'value')); + return $this->filterByOptions($records, $options); + } +} diff --git a/module/metric/test/calc/execution/scale/scale_of_story_in_execution_when_starting.php b/module/metric/test/calc/execution/scale/scale_of_story_in_execution_when_starting.php new file mode 100644 index 0000000000..a47d660972 --- /dev/null +++ b/module/metric/test/calc/execution/scale/scale_of_story_in_execution_when_starting.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +loadYaml('action_linkexecution', true, 4)->gen(10000); +zendata('product')->loadYaml('product', true, 4)->gen(10); +zendata('project')->loadYaml('project_type', true, 4)->gen(100); +zendata('story')->loadYaml('story_closeddate', true, 4)->gen(1000); +zendata('projectstory')->loadYaml('executionstory', true, 4)->gen(1000); + + +$metric = new metricTest(); +$calc = $metric->calcMetric(__FILE__); + +r(count($calc->getResult())) && p('') && e('11'); // 测试分组数。 + +r($calc->getResult(array('project' => '4'))) && p('0:value') && e('40'); // 测试项目4。