From 4686e1935d15096d2ec88800925149ac779256fb Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 28 Aug 2023 13:58:04 +0800 Subject: [PATCH] * Refactor getKanbanTasks method and case. --- module/execution/model.php | 17 +++++----- module/execution/test/execution.class.php | 14 ++++---- .../execution/test/model/getkanbantasks.php | 32 +++++++++---------- module/kanban/model.php | 2 +- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 13aa01f60a..28c51d44a6 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4559,22 +4559,23 @@ class executionModel extends model } /** - * Get Kanban tasks + * 获取看板的任务卡片数据。 + * Get the Kanban task card data. * - * @param int $executionID - * @param string $orderBy - * @param object $pager - * @param array|string $excludeTasks + * @param int $executionID + * @param string $orderBy + * @param object|null $pager + * @param array $excludeTasks * @access public - * @return void + * @return array */ - public function getKanbanTasks($executionID, $orderBy = 'status_asc, id_desc', $pager = null, $excludeTasks = '') + public function getKanbanTasks(int $executionID, string $orderBy = 'status_asc, id_desc', array $excludeTasks = array(), object|null $pager = null): array { $tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName') ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account') - ->where('t1.execution')->eq((int)$executionID) + ->where('t1.execution')->eq($executionID) ->andWhere('t1.deleted')->eq(0) ->andWhere('t1.parent')->ge(0) ->beginIF($excludeTasks)->andWhere('t1.id')->notIN($excludeTasks)->fi() diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index b38e2c77c5..4e8f68af73 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -2131,16 +2131,18 @@ class executionTest } /** - * function getKanbanTasks test by execution + * 获取看板的任务卡片数据。 + * Get the Kanban task card data. * - * @param string $executionID - * @param string $count + * @param int $executionID + * @param int $count + * @param array $excludeTasks * @access public - * @return array + * @return array|int */ - public function getKanbanTasksTest($executionID, $count) + public function getKanbanTasksTest(int $executionID, int $count, array $excludeTasks = array()): array|int { - $object = $this->executionModel->getKanbanTasks($executionID); + $object = $this->executionModel->getKanbanTasks($executionID, 'id_desc', $excludeTasks); if(dao::isError()) { diff --git a/module/execution/test/model/getkanbantasks.php b/module/execution/test/model/getkanbantasks.php index b43b1ceee5..984829bccf 100755 --- a/module/execution/test/model/getkanbantasks.php +++ b/module/execution/test/model/getkanbantasks.php @@ -30,25 +30,25 @@ $task->gen(30); /** title=测试executionModel->getKanbanTasksTest(); +timeout=0 cid=1 -pid=1 - -敏捷执行查询 >> 任务25,5 -瀑布执行查询 >> 任务29,7 -看板执行查询 >> 任务21,9 -敏捷执行查询统计 >> 10 -瀑布执行查询统计 >> 10 -看板执行查询统计 >> 10 */ -$executionIDList = array(5, 7, 9); -$count = array('0', '1'); +$executionIDList = array(5, 7, 9); +$count = array('0', '1'); +$excludeTaskIdList = array(21, 25, 29); $executionTester = new executionTest(); -r($executionTester->getKanbanTasksTest($executionIDList[0], $count[0])) && p('25:name,execution') && e('任务25,5'); // 敏捷执行查询 -r($executionTester->getKanbanTasksTest($executionIDList[1], $count[0])) && p('29:name,execution') && e('任务29,7'); // 瀑布执行查询 -r($executionTester->getKanbanTasksTest($executionIDList[2], $count[0])) && p('21:name,execution') && e('任务21,9'); // 看板执行查询 -r($executionTester->getKanbanTasksTest($executionIDList[0], $count[1])) && p() && e('10'); // 敏捷执行查询统计 -r($executionTester->getKanbanTasksTest($executionIDList[1], $count[1])) && p() && e('10'); // 瀑布执行查询统计 -r($executionTester->getKanbanTasksTest($executionIDList[2], $count[1])) && p() && e('10'); // 看板执行查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[0], $count[0])) && p('25:name,execution') && e('任务25,5'); // 敏捷执行查询 +r($executionTester->getKanbanTasksTest($executionIDList[1], $count[0])) && p('29:name,execution') && e('任务29,7'); // 瀑布执行查询 +r($executionTester->getKanbanTasksTest($executionIDList[2], $count[0])) && p('21:name,execution') && e('任务21,9'); // 看板执行查询 +r($executionTester->getKanbanTasksTest($executionIDList[0], $count[1])) && p() && e('10'); // 敏捷执行查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[1], $count[1])) && p() && e('10'); // 瀑布执行查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[2], $count[1])) && p() && e('10'); // 看板执行查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[0], $count[0], $excludeTaskIdList)) && p('1:name,execution') && e('任务1,5'); // 敏捷执行查询不包括任务25 +r($executionTester->getKanbanTasksTest($executionIDList[1], $count[0], $excludeTaskIdList)) && p('2:name,execution') && e('任务2,7'); // 瀑布执行查询不包括任务29 +r($executionTester->getKanbanTasksTest($executionIDList[2], $count[0], $excludeTaskIdList)) && p('3:name,execution') && e('任务3,9'); // 看板执行查询不包括任务21 +r($executionTester->getKanbanTasksTest($executionIDList[0], $count[1], $excludeTaskIdList)) && p() && e('9'); // 敏捷执行不包括任务25查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[1], $count[1], $excludeTaskIdList)) && p() && e('9'); // 瀑布执行不包括任务29查询统计 +r($executionTester->getKanbanTasksTest($executionIDList[2], $count[1], $excludeTaskIdList)) && p() && e('9'); // 看板执行不包括任务21查询统计 diff --git a/module/kanban/model.php b/module/kanban/model.php index bb9fcd4103..0ded7145b7 100755 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -2992,7 +2992,7 @@ class kanbanModel extends model } elseif($laneType == 'task') { - $tasks = $this->loadModel('execution')->getKanbanTasks($executionID, 'status_asc, id_desc', null, $otherCardList); + $tasks = $this->loadModel('execution')->getKanbanTasks($executionID, 'status_asc, id_desc', explode(',', $otherCardList)); foreach($tasks as $taskID => $task) { foreach($this->config->kanban->taskColumnStatusList as $colType => $status)