From aff83bc74766307063c851e2a77646d29917f405 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Thu, 2 Oct 2025 13:54:50 +0800 Subject: [PATCH] * [task#149685,done,0.1h,0h] Optimize code. --- module/testtask/model.php | 6 +++--- module/testtask/zen.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/module/testtask/model.php b/module/testtask/model.php index f5efeaf443..272d51f692 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1191,8 +1191,8 @@ class testtaskModel extends model /* Preprocess the query SQL generated by the search form. */ $allProduct = "`product` = 'all'"; $caseQuery = $this->session->testtaskQuery; - $isQueryAllProduct = strpos($caseQuery, $allProduct); - if($isQueryAllProduct !== false) $caseQuery = str_replace($allProduct, '1', $caseQuery) . ' AND `product` ' . helper::dbIN($this->app->user->view->products); + $isQueryProduct = strpos($caseQuery, "`product` = '"); + if($isQueryProduct !== false) $caseQuery = str_replace($allProduct, '1', $caseQuery) . ' AND `product` ' . helper::dbIN($this->app->user->view->products); $caseQuery = preg_replace('/`(\w+)`/', 't2.`$1`', $caseQuery); $caseQuery = str_replace(array('t2.`assignedTo`', 't2.`lastRunner`', 't2.`lastRunDate`', 't2.`lastRunResult`'), array('t1.`assignedTo`', 't1.`lastRunner`', 't1.`lastRunDate`', 't1.`lastRunResult`'), $caseQuery); @@ -1204,7 +1204,7 @@ class testtaskModel extends model ->where($caseQuery) ->andWhere('t1.task')->eq($task->id) ->andWhere('t2.deleted')->eq('0') - ->beginIF($isQueryAllProduct === false)->andWhere('t2.product')->eq($productID)->fi() + ->beginIF($isQueryProduct === false)->andWhere('t2.product')->eq($productID)->fi() ->beginIF($task->branch)->andWhere('t2.branch')->in("0,{$task->branch}")->fi() ->orderBy($orderBy) ->page($pager) diff --git a/module/testtask/zen.php b/module/testtask/zen.php index f844ac10be..17df483b53 100644 --- a/module/testtask/zen.php +++ b/module/testtask/zen.php @@ -97,6 +97,7 @@ class testtaskZen extends testtask unset($searchConfig['fields']['branch']); unset($searchConfig['params']['branch']); + $this->config->testcase->search = $searchConfig; $this->loadModel('search')->setSearchParams($searchConfig); } @@ -120,8 +121,8 @@ class testtaskZen extends testtask $searchConfig['actionURL'] = inlink('linkcase', "taskID={$task->id}&type={$type}¶m={$param}"); $searchConfig['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($product->id, 'case', 0, $task->branch); $searchConfig['params']['scene']['values'] = $this->testcase->getSceneMenu($product->id); - $searchConfig['params']['product']['values'] = array($product->id => $product->name); $searchConfig['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries(); + if(empty($searchConfig['params']['product'])) $searchConfig['params']['product']['values'] = array($product->id => $product->name); $build = $this->loadModel('build')->getByID((int)$task->build); if($build) @@ -313,7 +314,7 @@ class testtaskZen extends testtask * @access protected * @return void */ - protected function assignForCases(object $product, object $testtask, array $runs, array $scenes, int $moduleID, string $browseType, int $param, string $orderBy, object $pager): void + public function assignForCases(object $product, object $testtask, array $runs, array $scenes, int $moduleID, string $browseType, int $param, string $orderBy, object $pager): void { $suites = $this->loadModel('testsuite')->getSuitePairs($product->id);