* Optimize project overview block performance.

This commit is contained in:
tianshujie
2023-08-10 15:52:24 +08:00
parent 03e5c42a1d
commit 67564c6e4b
3 changed files with 18 additions and 15 deletions
+1
View File
@@ -38,6 +38,7 @@ ADD INDEX `objectType`(`objectType` ASC),
ADD INDEX `status`(`status` ASC);
CREATE INDEX deleted ON zt_bug (deleted);
CREATE INDEX project ON zt_bug (project);
CREATE INDEX product_status_deleted ON zt_bug (product,status,deleted);
UPDATE `zt_cron` SET `m` = '*/1' WHERE `command` in ('moduleName=mail&methodName=asyncSend', 'moduleName=webhook&methodName=asyncSend') and `type` = 'zentao';
+12 -9
View File
@@ -353,15 +353,18 @@ CREATE TABLE IF NOT EXISTS `zt_bug` (
`deleted` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX `product` ON `zt_bug`(`product`);
CREATE INDEX `execution` ON `zt_bug`(`execution`);
CREATE INDEX `status` ON `zt_bug`(`status`);
CREATE INDEX `plan` ON `zt_bug`(`plan`);
CREATE INDEX `story` ON `zt_bug`(`story`);
CREATE INDEX `case` ON `zt_bug`(`case`);
CREATE INDEX `toStory` ON `zt_bug`(`toStory`);
CREATE INDEX `result` ON `zt_bug`(`result`);
CREATE INDEX `assignedTo` ON `zt_bug`(`assignedTo`);
CREATE INDEX `product` ON `zt_bug`(`product`);
CREATE INDEX `execution` ON `zt_bug`(`execution`);
CREATE INDEX `status` ON `zt_bug`(`status`);
CREATE INDEX `plan` ON `zt_bug`(`plan`);
CREATE INDEX `story` ON `zt_bug`(`story`);
CREATE INDEX `case` ON `zt_bug`(`case`);
CREATE INDEX `toStory` ON `zt_bug`(`toStory`);
CREATE INDEX `result` ON `zt_bug`(`result`);
CREATE INDEX `assignedTo` ON `zt_bug`(`assignedTo`);
CREATE INDEX `deleted` ON `zt_bug`(`deleted`);
CREATE INDEX `project` ON `zt_bug`(`project`);
CREATE INDEX `product_status_deleted` ON `zt_bug` (`product`,`status`,`deleted`);
-- DROP TABLE IF EXISTS `zt_build`;
CREATE TABLE IF NOT EXISTS `zt_build` (
+5 -6
View File
@@ -395,12 +395,11 @@ class projectModel extends model
*/
public function getTotalTaskByProject($projectIdList)
{
return $this->dao->select("t1.project, count(t1.id) as allTasks, count(if(t1.status = 'wait', 1, null)) as waitTasks, count(if(t1.status = 'doing', 1, null)) as doingTasks, count(if(t1.status = 'done', 1, null)) as doneTasks, count(if(t1.status = 'wait' or t1.status = 'pause' or t1.status = 'cancel', 1, null)) as leftTasks, count(if(t1.status = 'done' or t1.status = 'closed', 1, null)) as litedoneTasks")->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution=t2.id')
->where('t1.project')->in($projectIdList)
->andWhere('t1.deleted')->eq(0)
->andWhere('t2.deleted')->eq(0)
->groupBy('t1.project')
$executionIdList = $this->dao->select('id')->from(TABLE_EXECUTION)->where('project')->in($projectIdList)->andWhere('deleted')->eq(0)->fetchPairs();
return $this->dao->select("project, count(id) as allTasks, count(if(status = 'wait', 1, null)) as waitTasks, count(if(status = 'doing', 1, null)) as doingTasks, count(if(status = 'done', 1, null)) as doneTasks, count(if(status = 'wait' or status = 'pause' or status = 'cancel', 1, null)) as leftTasks, count(if(status = 'done' or status = 'closed', 1, null)) as litedoneTasks")->from(TABLE_TASK)
->where('execution')->in($executionIdList)
->andWhere('deleted')->eq(0)
->groupBy('project')
->fetchAll('project');
}