* Refactor getSearchTasks method.
This commit is contained in:
@@ -3632,15 +3632,16 @@ class executionModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过搜索条件获取任务列表信息。
|
||||
* Get taskes by search.
|
||||
*
|
||||
* @param string $condition
|
||||
* @param object $pager
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSearchTasks($condition, $pager, $orderBy)
|
||||
public function getSearchTasks(string $condition, string $orderBy, object $pager = null): array
|
||||
{
|
||||
if(strpos($condition, '`assignedTo`') !== false)
|
||||
{
|
||||
@@ -3673,6 +3674,19 @@ class executionModel extends model
|
||||
|
||||
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'task', true);
|
||||
|
||||
return $this->processTasks($tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理任务,团队、父子层级、泳道等信息。
|
||||
* Batch process tasks, teams, parent-child, lanes, etc.
|
||||
*
|
||||
* @param array $tasks
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processTasks(array $tasks): array
|
||||
{
|
||||
if(empty($tasks)) return array();
|
||||
|
||||
$taskTeam = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->in(array_keys($tasks))->fetchGroup('task');
|
||||
|
||||
@@ -2240,47 +2240,28 @@ class executionTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get taskes by search.
|
||||
* 通过搜索条件获取任务列表信息。
|
||||
* Get taskes by search.
|
||||
*
|
||||
* @param string $condition
|
||||
* @param int $recPerPage
|
||||
* @param string $orderBy
|
||||
* @param int $recPerPage
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSearchTasksTest($condition, $recPerPage, $orderBy)
|
||||
public function getSearchTasksTest(string $condition, string $orderBy, int $recPerPage): array
|
||||
{
|
||||
global $tester;
|
||||
|
||||
/* Load pager. */
|
||||
global $tester, $app;
|
||||
$app->moduleName = 'execution';
|
||||
$app->methodName = 'searchtasks';
|
||||
$tester->app->loadClass('pager', $static = true);
|
||||
$pager = new pager(0, $recPerPage, 1);
|
||||
|
||||
$objects = $this->executionModel->getSearchTasks($condition, $pager, $orderBy);
|
||||
$objects = $this->executionModel->getSearchTasks($condition, $orderBy, $pager);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$returns = '';
|
||||
foreach($objects as $object)
|
||||
{
|
||||
$returns .= "$object->id:name:$object->name";
|
||||
if(!empty($object->team))
|
||||
{
|
||||
$returns .= ',team:[';
|
||||
foreach($object->team as $team) $returns .= "$team->id,";
|
||||
$returns = trim($returns, ',');
|
||||
$returns .= ']';
|
||||
}
|
||||
$returns .= ';';
|
||||
}
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
$error = dao::getError();
|
||||
return $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $returns;
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3006,4 +2987,24 @@ class executionTest
|
||||
|
||||
return $this->executionModel->appendTasks($executions[0]->tasks, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理任务,团队、父子层级、泳道等信息。
|
||||
* Batch process tasks, teams, parent-child, lanes, etc.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param int $count
|
||||
* @access public
|
||||
* @return array|int
|
||||
*/
|
||||
public function processTasksTest(int $executionID, int $count): array|int
|
||||
{
|
||||
$tasks = $this->executionModel->dao->select('*')->from(TABLE_TASK)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('execution')->eq($executionID)
|
||||
->fetchAll('id');
|
||||
|
||||
$tasks = $this->executionModel->processTasks($tasks);
|
||||
return $count ? count($tasks) : $tasks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,25 +36,8 @@ su('admin');
|
||||
/**
|
||||
|
||||
title=executionModel->getSearchTasks();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试通过sql语句获取3个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0 >> 10:name:任务10;9:name:任务9;8:name:任务8;
|
||||
测试通过sql语句获取3个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0 >> 1:name:任务1;3:name:任务3;
|
||||
测试通过sql语句获取5个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0 >> 10:name:任务10;9:name:任务9;8:name:任务8;7:name:任务7;6:name:任务6;
|
||||
测试通过sql语句获取5个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0 >> 1:name:任务1;3:name:任务3;5:name:任务5;
|
||||
测试通过sql语句获取3个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0 >> 8:name:任务8;2:name:任务2;
|
||||
测试通过sql语句获取3个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0 >> 2:name:任务2;8:name:任务8;
|
||||
测试通过sql语句获取5个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0 >> 8:name:任务8;2:name:任务2;
|
||||
测试通过sql语句获取5个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0 >> 2:name:任务2;8:name:任务8;
|
||||
测试通过sql语句获取3个任务 id 倒序 execution = '3' and story != '0' and parent >= 0 >> 10:name:任务10;8:name:任务8;6:name:任务6;
|
||||
测试通过sql语句获取3个任务 id 正序 execution = '3' and story != '0' and parent >= 0 >> 2:name:任务2;4:name:任务4;6:name:任务6;
|
||||
测试通过sql语句获取5个任务 id 倒序 execution = '3' and story != '0' and parent >= 0 >> 10:name:任务10;8:name:任务8;6:name:任务6;4:name:任务4;2:name:任务2;
|
||||
测试通过sql语句获取5个任务 id 正序 execution = '3' and story != '0' and parent >= 0 >> 2:name:任务2;4:name:任务4;6:name:任务6;8:name:任务8;10:name:任务10;
|
||||
测试通过sql语句获取3个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0 >> 6:name:任务6;
|
||||
测试通过sql语句获取3个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0 >> 6:name:任务6;
|
||||
测试通过sql语句获取5个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0 >> 6:name:任务6;
|
||||
测试通过sql语句获取5个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0 >> 6:name:任务6;
|
||||
|
||||
*/
|
||||
|
||||
@@ -68,19 +51,19 @@ $recPerPage = array('3', '5');
|
||||
$orderBy = array('id_desc', 'id_asc');
|
||||
|
||||
$execution = new executionTest();
|
||||
r($execution->getSearchTasksTest($condition[0], $recPerPage[0], $orderBy[0])) && p() && e('10:name:任务10;9:name:任务9;8:name:任务8;'); // 测试通过sql语句获取3个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $recPerPage[0], $orderBy[1])) && p() && e('1:name:任务1;3:name:任务3;'); // 测试通过sql语句获取3个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $recPerPage[1], $orderBy[0])) && p() && e('10:name:任务10;9:name:任务9;8:name:任务8;7:name:任务7;6:name:任务6;'); // 测试通过sql语句获取5个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $recPerPage[1], $orderBy[1])) && p() && e('1:name:任务1;3:name:任务3;5:name:任务5;'); // 测试通过sql语句获取5个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $recPerPage[0], $orderBy[0])) && p() && e('8:name:任务8;2:name:任务2;'); // 测试通过sql语句获取3个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $recPerPage[0], $orderBy[1])) && p() && e('2:name:任务2;8:name:任务8;'); // 测试通过sql语句获取3个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $recPerPage[1], $orderBy[0])) && p() && e('8:name:任务8;2:name:任务2;'); // 测试通过sql语句获取5个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $recPerPage[1], $orderBy[1])) && p() && e('2:name:任务2;8:name:任务8;'); // 测试通过sql语句获取5个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $recPerPage[0], $orderBy[0])) && p() && e('10:name:任务10;8:name:任务8;6:name:任务6;'); // 测试通过sql语句获取3个任务 id 倒序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $recPerPage[0], $orderBy[1])) && p() && e('2:name:任务2;4:name:任务4;6:name:任务6;'); // 测试通过sql语句获取3个任务 id 正序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $recPerPage[1], $orderBy[0])) && p() && e('10:name:任务10;8:name:任务8;6:name:任务6;4:name:任务4;2:name:任务2;'); // 测试通过sql语句获取5个任务 id 倒序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $recPerPage[1], $orderBy[1])) && p() && e('2:name:任务2;4:name:任务4;6:name:任务6;8:name:任务8;10:name:任务10;'); // 测试通过sql语句获取5个任务 id 正序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $recPerPage[0], $orderBy[0])) && p() && e('6:name:任务6;'); // 测试通过sql语句获取3个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $recPerPage[0], $orderBy[1])) && p() && e('6:name:任务6;'); // 测试通过sql语句获取3个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $recPerPage[1], $orderBy[0])) && p() && e('6:name:任务6;'); // 测试通过sql语句获取5个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $recPerPage[1], $orderBy[1])) && p() && e('6:name:任务6;'); // 测试通过sql语句获取5个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $orderBy[0], $recPerPage[0])) && p('10:name') && e('任务10'); // 测试通过sql语句获取3个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $orderBy[1], $recPerPage[0])) && p('1:name') && e('任务1'); // 测试通过sql语句获取3个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $orderBy[0], $recPerPage[1])) && p('10:name') && e('任务10'); // 测试通过sql语句获取5个任务 id 倒序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[0], $orderBy[1], $recPerPage[1])) && p('1:name') && e('任务1'); // 测试通过sql语句获取5个任务 id 正序 execution = '3' and deleted = '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $orderBy[0], $recPerPage[0])) && p('8:name') && e('任务8'); // 测试通过sql语句获取3个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $orderBy[1], $recPerPage[0])) && p('2:name') && e('任务2'); // 测试通过sql语句获取3个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $orderBy[0], $recPerPage[1])) && p('8:name') && e('任务8'); // 测试通过sql语句获取5个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[1], $orderBy[1], $recPerPage[1])) && p('2:name') && e('任务2'); // 测试通过sql语句获取5个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $orderBy[0], $recPerPage[0])) && p('10:name') && e('任务10'); // 测试通过sql语句获取3个任务 id 倒序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $orderBy[1], $recPerPage[0])) && p('2:name') && e('任务2'); // 测试通过sql语句获取3个任务 id 正序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $orderBy[0], $recPerPage[1])) && p('10:name') && e('任务10'); // 测试通过sql语句获取5个任务 id 倒序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[2], $orderBy[1], $recPerPage[1])) && p('2:name') && e('任务2'); // 测试通过sql语句获取5个任务 id 正序 execution = '3' and story != '0' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $orderBy[0], $recPerPage[0])) && p('6:name') && e('任务6'); // 测试通过sql语句获取3个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $orderBy[1], $recPerPage[0])) && p('6:name') && e('任务6'); // 测试通过sql语句获取3个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $orderBy[0], $recPerPage[1])) && p('6:name') && e('任务6'); // 测试通过sql语句获取5个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
|
||||
r($execution->getSearchTasksTest($condition[3], $orderBy[1], $recPerPage[1])) && p('6:name') && e('任务6'); // 测试通过sql语句获取5个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/execution.class.php';
|
||||
|
||||
zdTable('user')->gen(5);
|
||||
su('admin');
|
||||
|
||||
zdTable('project')->config('project')->gen(10);
|
||||
zdTable('taskteam')->config('taskteam')->gen(30);
|
||||
$task = zdTable('task')->config('task');
|
||||
$task->execution->range('2{5},3{2},4{2}');
|
||||
$task->gen(30);
|
||||
|
||||
/**
|
||||
|
||||
title=测试executionModel->processTasks();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
$executionIdList = array(0, 2, 3, 4);
|
||||
$count = array(0, 1);
|
||||
|
||||
$executionTester = new executionTest();
|
||||
r($executionTester->processTasksTest($executionIdList[0], $count[0])) && p() && e('0'); // 测试空数据
|
||||
r($executionTester->processTasksTest($executionIdList[1], $count[0])) && p('30:id,name') && e('30,开发任务40'); // 测试处理迭代下的任务信息
|
||||
r($executionTester->processTasksTest($executionIdList[2], $count[0])) && p('15:id,name') && e('15,开发任务25'); // 测试处理阶段下的任务信息
|
||||
r($executionTester->processTasksTest($executionIdList[3], $count[0])) && p('27:id,name') && e('27,开发任务37'); // 测试处理看板下的任务信息
|
||||
r($executionTester->processTasksTest($executionIdList[1], $count[1])) && p() && e('13'); // 获取处理迭代下的任务数量
|
||||
r($executionTester->processTasksTest($executionIdList[2], $count[1])) && p() && e('2'); // 获取处理阶段下的任务数量
|
||||
r($executionTester->processTasksTest($executionIdList[3], $count[1])) && p() && e('6'); // 获取处理看板下的任务数量
|
||||
Reference in New Issue
Block a user