* Optimize sql and code to improve query performance.

This commit is contained in:
chenfei
2020-05-04 17:40:46 +08:00
parent 6a2ce5fade
commit b919ac88dd
+4 -4
View File
@@ -310,16 +310,16 @@ class reportModel extends model
$stmt = $this->dao->select('t1.*, t2.name as projectName')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.deleted')->eq(0)
->andWhere('t1.status')->notin('cancel, closed, done, pause')
->andWhere('t1.status')->in('wait,doing')
->andWhere('t2.deleted')->eq(0)
->andWhere('t2.status')->notin('cancel, closed, done, suspended')
->andWhere('t2.status')->in('wait, doing')
->andWhere('assignedTo')->ne('');
$allTasks = $stmt->fetchAll('id');
$tasks = $stmt->beginIF($dept)->andWhere('t1.assignedTo')->in(array_keys($deptUsers))->fi()->fetchAll('id');
if(empty($allTasks)) return array();
$tasks = $stmt->beginIF($dept)->andWhere('t1.assignedTo')->in(array_keys($deptUsers))->fi()->fetchAll('id');
/* Fix bug for children. */
$parents = array();
$taskIdList = array();