* Add case of execution method.

This commit is contained in:
tianshujie
2023-02-18 20:16:52 +08:00
parent 73077a3615
commit b05cad4add
3 changed files with 85 additions and 1 deletions
+4 -1
View File
@@ -5609,6 +5609,7 @@ class executionModel extends model
*/
public function resetExecutionSorts($executions, $parentExecutions = array())
{
if(empty($executions)) return array();
if(empty($parentExecutions))
{
$execution = current($executions);
@@ -5616,6 +5617,7 @@ class executionModel extends model
->where('deleted')->eq(0)
->andWhere('type')->in('kanban,sprint,stage')
->andWhere('grade')->eq(1)
->andWhere('project')->eq($execution->project)
->orderBy('order_asc')
->fetchAll('id');
}
@@ -5623,9 +5625,10 @@ class executionModel extends model
$sortedExecutions = array();
foreach($parentExecutions as $executionID => $execution)
{
if(!isset($sortedExecutions[$executionID]) and isset($executions[$executionID])) $sortedExecutions[$executionID] = $executions[$executionID];
$children = $this->getChildExecutions($executionID, 'order_asc');
if(!empty($children)) $sortedExecutions += $this->resetExecutionSorts($executions, $children);
if(!isset($sortedExecutions[$executionID]) and isset($executions[$executionID])) $sortedExecutions[$executionID] = $executions[$executionID];
}
return $sortedExecutions;
}
+40
View File
@@ -2806,4 +2806,44 @@ class executionTest
->andWhere('date')->eq($date)
->orderBy('date DESC, id asc')->fetchGroup('name', 'date');
}
/**
* Reset execution sorts.
*
* @param int $projectID
* @param string $type noParent
* @access public
* @return string
*/
public function resetExecutionSortsTest($projectID, $type = '')
{
$executions = array();
$executionIDList = '';
$firstGradeExecutions = array();
if($projectID)
{
$executions = $this->executionModel->dao->select('*')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('project')->eq($projectID)
->andWhere('type')->in('sprint,stage,kanban')
->orderBy('order_asc')
->fetchAll('id');
if($type == 'hasParent')
{
foreach($executions as $execution)
{
if($execution->grade == 1) $firstGradeExecutions[$execution->id] = $execution->id;
}
}
}
$executions = $this->executionModel->resetExecutionSorts($executions, $firstGradeExecutions);
if(!empty($executions))
{
$executionIDList = array_keys($executions);
$executionIDList = implode(',', $executionIDList);
}
return $executionIDList;
}
}
@@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-8');
$execution->name->range('项目集1,项目1,需求阶段1,测试阶段1,需求子阶段1,需求子阶段2,需求子阶段1的迭代1,需求子阶段1的看板1');
$execution->model->range('[],waterfallplus,[]{6}');
$execution->type->range('program,project,stage{4},sprint,kanban');
$execution->project->range('0{2},2{6}');
$execution->parent->range('0,1,2{2},3{2},5{2}');
$execution->grade->range('1{4},2{2},3{2}');
$execution->path->range('`,1,`,`,1,2,`,`,1,2,3`,`,1,2,4,`,`,1,2,3,5,`,`,1,2,3,6,`,`,1,2,3,5,7,`,`1,2,3,5,8,`');
$execution->order->range('5,10,15,20,25,30,35,40');
$execution->status->range('doing');
$execution->openedBy->range('admin');
$execution->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->gen(8);
/**
title=测试executionModel->resetExecutionSorts();
cid=1
pid=1
检查没有执行时的排序 >> 0
检查有执行时的排序 >> 3,5,7,8,6,4
检查有执行并且传parenExecutions时的排序 >> 3,5,7,8,6,4
*/
$projectList = array(0, 2);
$executionTester = new executionTest();
r($executionTester->resetExecutionSortsTest($projectList[0])) && p() && e('0'); // 检查没有执行时的排序
r($executionTester->resetExecutionSortsTest($projectList[1])) && p() && e('3,5,7,8,6,4'); // 检查有执行时的排序
r($executionTester->resetExecutionSortsTest($projectList[1], 'hasParent')) && p() && e('3,5,7,8,6,4'); // 检查有执行并且传parenExecutions时的排序