+[task#125856,done,1.5h].

This commit is contained in:
songchenxuan
2024-08-09 15:04:25 +08:00
committed by 周鑫
parent 494798ad5f
commit 76b8a35e6a
3 changed files with 108 additions and 0 deletions
+14
View File
@@ -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的任务消耗工时占比',
@@ -0,0 +1,65 @@
<?php
/**
* 按执行统计的执行关闭时已交付的研发需求规模数
* Scale of story at execution begin.
*
* 范围:execution
* 对象:story
* 目的:scale
* 度量名称:按执行统计的截止执行开始当天的研发需求数
* 单位:hour
* 描述:按执行统计的截止执行开始当天的研发需求数表示执行开始当天已关联进执行的研发需求的数量。该度量项反映了本期执行计划完成的需求数量,可以用于评估执行团队的工作负载。
* 定义:截止到执行开始当天的23:59分的研发需求个数求和,过滤已删除的研发需求,过滤已删除的执行,过滤已删除的项目,过滤已删除的产品。
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author songchenxuan <songchenxuan@chandao.com>
* @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);
}
}
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=scale_of_story_in_beginning_execution
timeout=0
cid=1
- 测试分组数。 @6
- 测试项目4。第0条的value属性 @40
*/
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/lib/calc.unittest.class.php';
zendata('action')->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。