From 2e820a5292cb45ac9f9c66833f6ba8aa30e0c799 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 4 Dec 2024 14:29:16 +0800 Subject: [PATCH] * [perf story #69214] Adjust code. --- module/cron/model.php | 2 +- module/execution/model.php | 22 +++++++++--------- module/execution/ui/view.html.php | 37 ++++++++++++------------------- module/program/tao.php | 2 +- module/user/model.php | 2 +- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/module/cron/model.php b/module/cron/model.php index f0af1691e9..c433990587 100755 --- a/module/cron/model.php +++ b/module/cron/model.php @@ -40,7 +40,7 @@ class cronModel extends model ->andWhere('command')->ne('moduleName=measurement&methodName=initCrontabQueue') ->andWhere('command')->ne('moduleName=measurement&methodName=execCrontabQueue') ->fi() - ->fetchAll('id'); + ->fetchAll('id', false); } /** diff --git a/module/execution/model.php b/module/execution/model.php index a5eb448cea..7a1e8adbfa 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -228,7 +228,7 @@ class executionModel extends model */ public function setProjectSession(int $executionID) { - $execution = $this->getByID($executionID); + $execution = $this->fetchByID($executionID); if(!empty($execution)) $this->session->set('project', $execution->project, $this->app->tab); } @@ -701,7 +701,7 @@ class executionModel extends model */ public function start(int $executionID, object $postData): array|false { - $oldExecution = $this->getById($executionID); + $oldExecution = $this->fetchById($executionID); $execution = $postData; if(!empty($postData->uid)) $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->start['id'], $postData->uid); @@ -744,7 +744,7 @@ class executionModel extends model */ public function putoff(int $executionID, object $postData): array|false { - $oldExecution = $this->getById($executionID); + $oldExecution = $this->fetchById($executionID); $this->checkBeginAndEndDate($oldExecution->project, $postData->begin, $postData->end); if(dao::isError()) return false; @@ -779,7 +779,7 @@ class executionModel extends model */ public function suspend(int $executionID, object $postData): array|false { - $oldExecution = $this->getById($executionID); + $oldExecution = $this->fetchById($executionID); $execution = $this->loadModel('file')->processImgURL($postData, $this->config->execution->editor->suspend['id'], (string)$this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution, 'comment') @@ -810,7 +810,7 @@ class executionModel extends model */ public function activate(int $executionID, object $postData): array|false { - $oldExecution = $this->getById($executionID); + $oldExecution = $this->fetchById($executionID); if(empty($oldExecution->totalConsumed) and helper::isZeroDate($oldExecution->realBegan)) $postData->status = 'wait'; @@ -912,7 +912,7 @@ class executionModel extends model */ public function close(int $executionID, object $postData): array|false { - $oldExecution = $this->getById($executionID); /* Save previous execution to variable for later compare. */ + $oldExecution = $this->fetchById($executionID); /* Save previous execution to variable for later compare. */ $this->lang->error->ge = $this->lang->execution->ge; @@ -1048,13 +1048,13 @@ class executionModel extends model */ public function checkBeginAndEndDate(int $projectID, string $begin, string $end, int $parentID = 0) { - $project = $this->loadModel('project')->getByID($projectID); + $project = $this->loadModel('project')->fetchByID($projectID); if(empty($project)) return; if(in_array($project->model, array('waterfall', 'waterfallplus', 'ipd')) && $parentID != $projectID) { $this->app->loadLang('programplan'); - $parent = $this->getByID($parentID); + $parent = $this->fetchByID($parentID); if($parent && $begin < $parent->begin) dao::$errors['begin'] = sprintf($this->lang->programplan->error->letterParent, $parent->begin); if($parent && $end > $parent->end) dao::$errors['end'] = sprintf($this->lang->programplan->error->greaterParent, $parent->end); } @@ -1549,7 +1549,7 @@ class executionModel extends model { if(commonModel::isTutorialMode()) return $this->loadModel('tutorial')->getExecutionPairs(); - $project = $this->loadModel('project')->getByID($projectID); + $project = $this->loadModel('project')->fetchByID($projectID); $executions = $this->dao->select('*')->from(TABLE_EXECUTION) ->where('type')->in('stage,sprint,kanban') ->andWhere('deleted')->eq('0') @@ -2332,8 +2332,8 @@ class executionModel extends model */ public function getTasks2Imported(int $toExecution, array $branches, string $orderBy = 'id_desc'): array { - $execution = $this->getById($toExecution); - $project = $this->loadModel('project')->getById($execution->project); + $execution = $this->fetchById($toExecution); + $project = $this->loadModel('project')->fetchById($execution->project); $brotherProjects = $this->project->getBrotherProjects($project); $executions = $this->dao->select('id')->from(TABLE_EXECUTION) ->where('project')->in($brotherProjects) diff --git a/module/execution/ui/view.html.php b/module/execution/ui/view.html.php index ecc30f0182..11520c24cf 100644 --- a/module/execution/ui/view.html.php +++ b/module/execution/ui/view.html.php @@ -330,30 +330,21 @@ foreach(array('PM', 'PO', 'QD', 'RD') as $field) if(empty($execution->$field)) continue; $user = isset($userList[$execution->$field]) ? $userList[$execution->$field] : null; - if($user) - { - $membersDom[] = div + if(empty($user)) continue; + + $membersDom[] = div + ( + setClass('w-1/8 center-y'), + avatar ( - setClass('w-1/8 center-y'), - avatar - ( - setClass('primary-outline'), - set::size('36'), - set::text($user->realname), - set::src($user->avatar) - ), - span - ( - setClass('my-2'), - $user->realname - ), - span - ( - setClass('text-gray'), - $lang->execution->$field - ) - ); - } + setClass('primary-outline'), + set::size('36'), + set::text($user->realname), + set::src($user->avatar) + ), + span(setClass('my-2'), $user->realname), + span(setClass('text-gray'), $lang->execution->$field) + ); unset($teamMembers[$execution->$field]); } diff --git a/module/program/tao.php b/module/program/tao.php index 30e580702b..00dad46293 100644 --- a/module/program/tao.php +++ b/module/program/tao.php @@ -279,7 +279,7 @@ class programTao extends programModel $tasks = $this->dao->select('t1.id, execution, t1.estimate, t1.consumed, t1.`left`, t1.status')->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id') ->where('t1.deleted')->eq(0) - ->andWhere('t1.isParent')->ne('1') // Ignore parent task. + ->andWhere('t1.isParent')->eq('0') // Ignore parent task. ->andWhere('t2.deleted')->eq(0) ->beginIF(!empty($projectIdList))->andWhere('t2.project')->in($projectIdList)->fi() ->fetchAll('id'); diff --git a/module/user/model.php b/module/user/model.php index 33ab951e25..b838d1cb3f 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -190,7 +190,7 @@ class userModel extends model ->beginIF(strpos($params, 'all') === false)->andWhere('type')->eq('inside')->fi() ->beginIF(strpos($params, 'nodeleted') !== false)->andWhere('deleted')->eq(0)->fi() ->orderBy('account') - ->fetchAll(); + ->fetchAll('', false); } /**