* Refactor getInvolvedExecutionList method.

This commit is contained in:
tianshujie
2023-08-30 09:38:20 +08:00
parent f9aa5e6f64
commit a8cd6cf66d
3 changed files with 32 additions and 31 deletions
+13 -12
View File
@@ -1750,17 +1750,18 @@ class executionModel extends model
}
/**
* Get involved execution list.
* 获取我参与的执行列表信息。
* Get involved execution list information.
*
* @param int $projectID
* @param string $status involved
* @param int $limit
* @param int $productID
* @param int $branch
* @param int $projectID
* @param string $status involved
* @param int $limit
* @param int $productID
* @param int $branch
* @access public
* @return array
* @return object[]
*/
public function getInvolvedExecutionList($projectID = 0, $status = 'involved', $limit = 0, $productID = 0, $branch = 0)
public function getInvolvedExecutionList(int $projectID = 0, string $status = 'involved', int $limit = 0, int $productID = 0, int $branch = 0): array
{
if($productID != 0)
{
@@ -1769,13 +1770,13 @@ class executionModel extends model
->leftJoin(TABLE_TEAM)->alias('t3')->on('t3.root=t2.id')
->where('t1.product')->eq($productID)
->andWhere('t2.deleted')->eq(0)
->andWhere('t2.type')->in('sprint,stage,kanban')
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi()
->beginIF($projectID)->andWhere('t2.project')->eq($projectID)->fi()
->andWhere('t2.openedBy', true)->eq($this->app->user->account)
->orWhere('t3.account')->eq($this->app->user->account)
->markRight(1)
->andWhere('t2.type')->in('sprint,stage,kanban')
->beginIF($projectID)->andWhere('t2.project')->eq($projectID)->fi()
->orderBy('order_desc')
->beginIF($limit)->limit($limit)->fi()
->fetchAll('id');
@@ -1785,12 +1786,12 @@ class executionModel extends model
return $this->dao->select("t1.*, IF(INSTR(' done,closed', t1.status) < 2, 0, 1) AS isDone")->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_TEAM)->alias('t2')->on('t2.root=t1.id')
->where('t1.deleted')->eq(0)
->andWhere('t1.type')->in('sprint,stage,kanban')
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi()
->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()
->andWhere('t1.openedBy', true)->eq($this->app->user->account)
->orWhere('t2.account')->eq($this->app->user->account)
->markRight(1)
->andWhere('t1.type')->in('sprint,stage,kanban')
->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()
->orderBy('t1.order_desc')
->beginIF($limit)->limit($limit)->fi()
->fetchAll('id');
+9 -8
View File
@@ -736,18 +736,19 @@ class executionTest
}
/**
* fnction getInvolvedExecutionList test by execution
* 获取我参与的执行列表信息。
* Get involved execution list information.
*
* @param string $projectID
* @param string $limit
* @param string $productID
* @param string $count
* @param int $projectID
* @param int $limit
* @param int $productID
* @param int $count
* @access public
* @return array
* @return array|int
*/
public function getInvolvedExecutionListTest($projectID, $limit, $productID, $count)
public function getInvolvedExecutionListTest(int $projectID, int $limit, int $productID, int $count): array|int
{
$object = $this->executionModel->getInvolvedExecutionList($projectID,$status = 'involved',$limit, $productID);
$object = $this->executionModel->getInvolvedExecutionList($projectID, $status = 'involved', $limit, $productID);
if(dao::isError())
{
@@ -39,23 +39,22 @@ $projectProduct->gen(14);
/**
title=测试executionModel->getInvolvedExecutionListTest();
timeout=0
cid=1
pid=1
根据项目查询执行列表 >> 2,迭代1
根据产品查询执行列表 >> 2,迭代1,sprint
根据项目查询执行数量 >> 1
根据产品查询执行数量 >> 1
*/
$projectIDList = array(0, 2);
$projectIDList = array(0, 2, 3,4);
$productIDList = array(0, 1);
$limit = array(0, 2, 10);
$count = array(0, 1);
$executionTester = new executionTest();
r($executionTester->getInvolvedExecutionListTest($projectIDList[1],$limit[0],$productIDList[0],$count[0])) && p('5:project,name') && e('2,迭代1'); // 根据项目查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[0],$limit[0],$productIDList[1],$count[0])) && p('5:project,name,type') && e('2,迭代1,sprint'); // 根据产品查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[1],$limit[1],$productIDList[0],$count[1])) && p() && e('1'); // 根据项目查询执行数量
r($executionTester->getInvolvedExecutionListTest($projectIDList[0],$limit[2],$productIDList[1],$count[1])) && p() && e('1'); // 根据产品查询执行数量
r($executionTester->getInvolvedExecutionListTest($projectIDList[1], $limit[0], $productIDList[0], $count[0])) && p('5:project,name') && e('2,迭代1'); // 根据敏捷项目查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[2], $limit[0], $productIDList[0], $count[0])) && p('7:project,name') && e('3,阶段1'); // 根据瀑布项目查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[3], $limit[0], $productIDList[0], $count[0])) && p('9:project,name') && e('4,看板1'); // 根据看板项目查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[0], $limit[0], $productIDList[1], $count[0])) && p('5:project,name,type') && e('2,迭代1,sprint'); // 根据产品查询执行列表
r($executionTester->getInvolvedExecutionListTest($projectIDList[1], $limit[1], $productIDList[0], $count[1])) && p() && e('1'); // 根据敏捷项目查询执行数量
r($executionTester->getInvolvedExecutionListTest($projectIDList[2], $limit[1], $productIDList[0], $count[1])) && p() && e('1'); // 根据瀑布项目查询执行数量
r($executionTester->getInvolvedExecutionListTest($projectIDList[3], $limit[1], $productIDList[0], $count[1])) && p() && e('1'); // 根据看板项目查询执行数量
r($executionTester->getInvolvedExecutionListTest($projectIDList[0], $limit[2], $productIDList[1], $count[1])) && p() && e('1'); // 根据产品查询执行数量