* [task#149685,done,0.1h,0h] Optimize code.

This commit is contained in:
wangyuting
2025-11-18 08:31:33 +08:00
parent 56472b29c1
commit aff83bc747
2 changed files with 6 additions and 5 deletions
+3 -3
View File
@@ -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)
+3 -2
View File
@@ -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}&param={$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);