* Optimize getCount,getTodoProjects functions.
This commit is contained in:
@@ -377,6 +377,12 @@ define('TABLE_PRIVLANG', '`' . $config->db->prefix . 'privlang`');
|
||||
define('TABLE_PRIVMANAGER', '`' . $config->db->prefix . 'privmanager`');
|
||||
define('TABLE_PRIVRELATION', '`' . $config->db->prefix . 'privrelation`');
|
||||
|
||||
define('TABLE_ISSUE', '`' . $config->db->prefix . 'issue`');
|
||||
define('TABLE_RISK', '`' . $config->db->prefix . 'risk`');
|
||||
define('TABLE_OPPORTUNITY', '`' . $config->db->prefix . 'opportunity`');
|
||||
define('TABLE_REVIEW', '`' . $config->db->prefix . 'review`');
|
||||
|
||||
|
||||
$config->objectTables['product'] = TABLE_PRODUCT;
|
||||
$config->objectTables['productplan'] = TABLE_PRODUCTPLAN;
|
||||
$config->objectTables['story'] = TABLE_STORY;
|
||||
|
||||
@@ -49,3 +49,13 @@ $config->todo->sessionUri['bugList'] = 'qa';
|
||||
$config->todo->sessionUri['taskList'] = 'execution';
|
||||
$config->todo->sessionUri['storyList'] = 'product';
|
||||
$config->todo->sessionUri['testtaskList'] = 'qa';
|
||||
|
||||
$config->todo->project = array();
|
||||
$config->todo->project['task'] = TABLE_TASK;
|
||||
$config->todo->project['bug'] = TABLE_BUG;
|
||||
$config->todo->project['issue'] = TABLE_ISSUE;
|
||||
$config->todo->project['risk'] = TABLE_RISK;
|
||||
$config->todo->project['opportunity'] = TABLE_OPPORTUNITY;
|
||||
$config->todo->project['review'] = TABLE_REVIEW;
|
||||
$config->todo->project['testtask'] = TABLE_TESTTASK;
|
||||
|
||||
|
||||
@@ -340,9 +340,9 @@ class todo extends control
|
||||
* @param string $todoID
|
||||
* @param string $confirm yes|no
|
||||
* @access public
|
||||
* @return int
|
||||
* @return void
|
||||
*/
|
||||
public function delete(string $todoID, string $confirm = 'no'): int
|
||||
public function delete(string $todoID, string $confirm = 'no')
|
||||
{
|
||||
$todoID = (int)$todoID;
|
||||
if($confirm == 'no') return print(js::confirm($this->lang->todo->confirmDelete, $this->createLink('todo', 'delete', "todoID={$todoID}&confirm=yes")));
|
||||
@@ -372,9 +372,9 @@ class todo extends control
|
||||
*
|
||||
* @param string $todoID
|
||||
* @access public
|
||||
* @return int|false
|
||||
* @return void
|
||||
*/
|
||||
public function finish(string $todoID): int|false
|
||||
public function finish(string $todoID)
|
||||
{
|
||||
$todoID = (int)$todoID;
|
||||
$todo = $this->todo->getByID($todoID);
|
||||
@@ -414,9 +414,9 @@ class todo extends control
|
||||
* Batch finish todos.
|
||||
*
|
||||
* @access public
|
||||
* @return int|false
|
||||
* @return void
|
||||
*/
|
||||
public function batchFinish(): int|false
|
||||
public function batchFinish()
|
||||
{
|
||||
$todoIDList = form::data($this->config->todo->batchFinish->form)->get('todoIDList');
|
||||
$todoList = $this->todo->getByList($todoIDList);
|
||||
|
||||
+18
-25
@@ -569,7 +569,7 @@ class todoModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 指派待办.
|
||||
* 指派待办。
|
||||
* Assign todo.
|
||||
*
|
||||
* @param object $todo
|
||||
@@ -586,56 +586,49 @@ class todoModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待办数量。
|
||||
* Get todo count.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getCount($account = '')
|
||||
public function getCount(string $account = ''): int
|
||||
{
|
||||
if(empty($account)) $account = $this->app->user->account;
|
||||
return $this->dao->select('count(*) as count')->from(TABLE_TODO)
|
||||
->where('cycle')->eq('0')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->andWhere('account', true)->eq($account)
|
||||
->orWhere('assignedTo')->eq($account)
|
||||
->orWhere('finishedBy')->eq($account)
|
||||
->markRight(1)
|
||||
->fetch('count');
|
||||
$count = $this->todoTao->getCountByAccount($account, $this->config->vision);
|
||||
if(dao::isError()) return 0;
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取各个模块的列表。
|
||||
* Gets the project ID of the to-do object.
|
||||
*
|
||||
* @param array $todoList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTodoProjects($todoList = array())
|
||||
public function getTodoProjects(array $todoList): array
|
||||
{
|
||||
$projectIdList = array();
|
||||
$projectIDList = array();
|
||||
$projects = $this->config->todo->project;
|
||||
foreach($todoList as $type => $todos)
|
||||
{
|
||||
$todoIdList = array_keys($todos);
|
||||
if(empty($todoIdList))
|
||||
$todoIDList = array_keys($todos);
|
||||
if(empty($todoIDList))
|
||||
{
|
||||
$projectIdList[$type] = array();
|
||||
$projectIDList[$type] = array();
|
||||
continue;
|
||||
}
|
||||
|
||||
$todoIdList = array_unique($todoIdList);
|
||||
if($type == 'task') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_TASK)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'bug') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_BUG)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'issue') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_ISSUE)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'risk') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_RISK)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'opportunity') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_OPPORTUNITY)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'review') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_REVIEW)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
if($type == 'testtask') $projectIdList[$type] = $this->dao->select('id,project')->from(TABLE_TESTTASK)->where('id')->in($todoIdList)->fetchPairs('id', 'project');
|
||||
$todoIDList = array_unique($todoIDList);
|
||||
|
||||
if(isset($projects[$type])) $projectIDList[$type] = $this->todoTao->getProjectList($projects[$type], $todoIDList);
|
||||
if(dao::isError()) return array();
|
||||
}
|
||||
|
||||
return $projectIdList;
|
||||
return $projectIDList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,42 @@ class todoTao extends todoModel
|
||||
return $this->dao->select('*')->from(TABLE_TODO)->where('id')->eq($todoID)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待办数量。
|
||||
* Get todo count.
|
||||
*
|
||||
* @param string $account
|
||||
* @param string $vision
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function getCountByAccount(string $account, string $vision = 'rnd'): int
|
||||
{
|
||||
return $this->dao->select('count(*) as count')->from(TABLE_TODO)
|
||||
->where('cycle')->eq('0')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('vision')->eq($vision)
|
||||
->andWhere('account', true)->eq($account)
|
||||
->orWhere('assignedTo')->eq($account)
|
||||
->orWhere('finishedBy')->eq($account)
|
||||
->markRight(1)
|
||||
->fetch('count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取各模块列表。
|
||||
* Get project list.
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $idList
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function getProjectList(string $table, array $idList): array
|
||||
{
|
||||
return $this->dao->select('id,project')->from($table)->where('id')->in($idList)->fetchPairs('id', 'project');
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入待办数据
|
||||
* Insert todo data.
|
||||
|
||||
Reference in New Issue
Block a user