From a8cd6cf66d1ac04579bc2ad859f9695aad442948 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 30 Aug 2023 09:38:13 +0800 Subject: [PATCH] * Refactor getInvolvedExecutionList method. --- module/execution/model.php | 25 ++++++++++--------- module/execution/test/execution.class.php | 17 +++++++------ .../test/model/getinvolvedexecutionlist.php | 21 ++++++++-------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 830d4d29f8..e63b123536 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -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'); diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 85cf951314..165414e1bb 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -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()) { diff --git a/module/execution/test/model/getinvolvedexecutionlist.php b/module/execution/test/model/getinvolvedexecutionlist.php index 1d856289e0..5e7712a0f8 100755 --- a/module/execution/test/model/getinvolvedexecutionlist.php +++ b/module/execution/test/model/getinvolvedexecutionlist.php @@ -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'); // 根据产品查询执行数量