From d8ef00183bf0bf95e88706a575d8029a07cb9412 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 6 Apr 2022 13:47:49 +0800 Subject: [PATCH 1/2] * Fix bug#17296. --- module/testreport/model.php | 7 +++++-- module/testtask/control.php | 14 ++++++-------- module/testtask/js/create.js | 1 - module/testtask/model.php | 14 -------------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/module/testreport/model.php b/module/testreport/model.php index 541f4ac595..cc9f765121 100644 --- a/module/testreport/model.php +++ b/module/testreport/model.php @@ -578,13 +578,16 @@ class testreportModel extends model * Get pairs. * * @param int $productID + * @param int $includedID * @access public * @return array */ - public function getPairs($productID = 0) + public function getPairs($productID = 0, $includedID = 0) { return $this->dao->select('id,title')->from(TABLE_TESTREPORT) - ->beginIF($productID)->where('product')->eq($productID)->fi() + ->where('deleted')->eq(0) + ->beginIF($productID)->andWhere('product')->eq($productID)->fi() + ->beginIF($includedID)->orWhere('id')->eq($includedID)->fi() ->orderBy('id_desc') ->fetchPairs(); } diff --git a/module/testtask/control.php b/module/testtask/control.php index 785a6c9384..557624257f 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -242,13 +242,12 @@ class testtask extends control } /* Create testtask from testtask of test.*/ - $productID = $productID ? $productID : key($this->products); - $executions = empty($productID) ? array() : $this->loadModel('product')->getExecutionPairsByProduct($productID, '', 'id_desc', $projectID); - $builds = empty($productID) ? array() : $this->loadModel('build')->getBuildPairs($productID, 'all', 'notrunk'); - $testreports = $this->testtask->getTestReportPairsByBuild($build); + $productID = $productID ? $productID : key($this->products); + $executions = empty($productID) ? array() : $this->loadModel('product')->getExecutionPairsByProduct($productID, '', 'id_desc', $projectID); + $builds = empty($productID) ? array() : $this->loadModel('build')->getBuildPairs($productID, 'all', 'notrunk'); /* Set menu. */ - $productID = $this->product->saveState($productID, $this->products); + $productID = $this->product->saveState($productID, $this->products); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->create; $this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]); @@ -261,7 +260,7 @@ class testtask extends control $this->view->executions = $executions; $this->view->builds = $builds; $this->view->build = $build; - $this->view->testreports = $testreports; + $this->view->testreports = array('') + $this->loadModel('testreport')->getPairs($productID); $this->view->users = $this->loadModel('user')->getPairs('noclosed|qdfirst|nodeleted'); $this->display(); @@ -758,12 +757,11 @@ class testtask extends control $executions = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID); $executionID = $task->execution; $builds = empty($productID) ? array() : $this->loadModel('build')->getBuildPairs($productID, 'all', 'noempty,notrunk', $executionID, 'execution'); - $testreports = $this->loadModel('testreport')->getPairs($task->product); $this->view->task = $task; $this->view->executions = $executions; $this->view->builds = $builds; - $this->view->testreports = $testreports; + $this->view->testreports = $this->loadModel('testreport')->getPairs($task->product, $task->testreport); $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed', $task->owner); $this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote'); diff --git a/module/testtask/js/create.js b/module/testtask/js/create.js index b893254a18..8e0df381da 100755 --- a/module/testtask/js/create.js +++ b/module/testtask/js/create.js @@ -38,6 +38,5 @@ function loadExecutions(productID) $(function() { adjustPriBoxWidth(); - loadTestReports($('#product').val()); if($('#execution').val() != 0) loadExecutionBuilds($('#execution').val()); }); diff --git a/module/testtask/model.php b/module/testtask/model.php index 3845a79242..76c13112a9 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -492,20 +492,6 @@ class testtaskModel extends model ->fetchAll(); } - /** - * Get test report pairs by build. - * - * @param string $build - * @access public - * @return array - */ - public function getTestReportPairsByBuild($build = '') - { - if(empty($build)) return array(); - - return $this->dao->select('id,title')->from(TABLE_TESTREPORT)->where("CONCAT(',', builds, ',')")->like("%,$build,%")->fetchPairs('id','title'); - } - /** * Get related test tasks. * From 22a74fe4bcfad9149b4bff476e98602235d150f3 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 6 Apr 2022 17:09:08 +0800 Subject: [PATCH 2/2] * Modify review code. --- module/testreport/model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/testreport/model.php b/module/testreport/model.php index cc9f765121..300a932aaa 100644 --- a/module/testreport/model.php +++ b/module/testreport/model.php @@ -578,16 +578,16 @@ class testreportModel extends model * Get pairs. * * @param int $productID - * @param int $includedID + * @param int $appendID * @access public * @return array */ - public function getPairs($productID = 0, $includedID = 0) + public function getPairs($productID = 0, $appendID = 0) { return $this->dao->select('id,title')->from(TABLE_TESTREPORT) ->where('deleted')->eq(0) ->beginIF($productID)->andWhere('product')->eq($productID)->fi() - ->beginIF($includedID)->orWhere('id')->eq($includedID)->fi() + ->beginIF($appendID)->orWhere('id')->eq($appendID)->fi() ->orderBy('id_desc') ->fetchPairs(); }