From 8a54569740bd426ca8ae88e5028ea357c4473445 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 29 Nov 2024 16:44:04 +0800 Subject: [PATCH] * [misc] Optimize the code for related object. --- module/bug/zen.php | 5 +++-- module/design/control.php | 4 ++-- module/execution/control.php | 5 +++-- module/testcase/zen.php | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/module/bug/zen.php b/module/bug/zen.php index 71e804c46d..001496c6c2 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -770,6 +770,7 @@ class bugZen extends bug /* Get story and task id list. */ $storyIdList = $taskIdList = array(); if($this->config->edition == 'max') $identifyList = $this->loadModel('review')->getPairs(0, 0, true); + if($this->config->edition != 'open') $bugRelatedObjectList = $this->custom->getRelatedObjectList(array_keys($bugs), 'bug', 'byRelation', true); foreach($bugs as $bug) { if($bug->story) $storyIdList[$bug->story] = $bug->story; @@ -781,10 +782,10 @@ class bugZen extends bug $bug->injection = zget($identifyList, $bug->injection, ''); $bug->identify = zget($identifyList, $bug->identify, ''); } - - if($this->config->edition != 'open') $bug->relatedObject = $this->custom->getRelatedObjectList($bug->id, 'bug', 'byRelation', true); + if($this->config->edition != 'open') $bug->relatedObject = zget($bugRelatedObjectList, $bug->id, 0); } + $showModule = !empty($this->config->bug->browse->showModule) ? $this->config->bug->browse->showModule : ''; /* Set view. */ diff --git a/module/design/control.php b/module/design/control.php index 6ac89e189a..b2e96d868b 100755 --- a/module/design/control.php +++ b/module/design/control.php @@ -115,8 +115,8 @@ class design extends control $designs = $this->design->getList($projectID, $productID, $type, $queryID, $orderBy, $pager); if($this->config->edition != 'open') { - $this->loadModel('custom'); - foreach($designs as $design) $design->relatedObject = $this->custom->getRelatedObjectList($design->id, 'design', 'byRelation', true); + $designRelatedObjectList = $this->loadModel('custom')->getRelatedObjectList(array_keys($designs), 'design', 'byRelation', true); + foreach($designs as $design) $design->relatedObject = zget($designRelatedObjectList, $design->id, 0); } $this->view->title = $this->lang->design->common . $this->lang->hyphen . $this->lang->design->browse; diff --git a/module/execution/control.php b/module/execution/control.php index 91c748d000..4a539e9f49 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -161,9 +161,10 @@ class execution extends control foreach($this->view->teamMembers as $key => $member) $memberPairs[$key] = $member->realname; $memberPairs = $this->loadModel('user')->setCurrentUserFirst($memberPairs); + if($this->config->edition != 'open') $taskRelatedObject = $this->loadModel('custom')->getRelatedObjectList(array_keys($tasks), 'task', 'byRelation', true); + /* Append branches to task. */ $this->loadModel('task'); - $this->loadModel('custom'); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($this->view->products)); foreach($tasks as $task) { @@ -183,7 +184,7 @@ class execution extends control } if(isset($branchGroups[$task->product][$task->branch])) $task->branch = $branchGroups[$task->product][$task->branch]; if($task->needConfirm) $task->status = 'changed'; - if($this->config->edition != 'open') $task->relatedObject = $this->custom->getRelatedObjectList($task->id, 'task', 'byRelation', true); + if($this->config->edition != 'open') $task->relatedObject = zget($taskRelatedObject, $task->id, 0); } $showAllModule = empty($this->config->execution->task->allModule) ? '' : 'allModule'; diff --git a/module/testcase/zen.php b/module/testcase/zen.php index f0dd026153..9352c32fa7 100755 --- a/module/testcase/zen.php +++ b/module/testcase/zen.php @@ -519,8 +519,8 @@ class testcaseZen extends testcase if($this->config->edition != 'open') { - $this->loadModel('custom'); - foreach($cases as $caseID => $case) $case->relatedObject = $this->custom->getRelatedObjectList($caseID, 'testcase', 'byRelation', true); + $caseRelatedObjectList = $this->loadModel('custom')->getRelatedObjectList(array_keys($cases), 'testcase', 'byRelation', true); + foreach($cases as $caseID => $case) $case->relatedObject = zget($caseRelatedObjectList, $caseID, 0); } $this->view->cases = array_merge($scenes, $cases);