From bb5b3426f61fd51dfa753a694a94f83754be79cc Mon Sep 17 00:00:00 2001 From: wangyuting <851424971@qq.com> Date: Mon, 14 Nov 2022 07:55:25 +0000 Subject: [PATCH 1/3] * Finish task #76032. --- module/bug/model.php | 37 +++++++++++++++++++++---------- module/build/control.php | 2 +- module/build/lang/de.php | 1 + module/build/lang/en.php | 1 + module/build/lang/fr.php | 1 + module/build/lang/vi.php | 1 + module/build/lang/zh-cn.php | 1 + module/build/model.php | 31 ++++++++++++++++++++++++++ module/build/view/create.html.php | 1 + 9 files changed, 63 insertions(+), 13 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 5d17a0c4af..093a93235f 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1888,19 +1888,19 @@ class bugModel extends model /** * Get bugs of a execution. * - * @param int $executionID - * @param int $productID - * @param int $branchID - * @param int $build - * @param string $type - * @param int $param - * @param string $orderBy - * @param string $excludeBugs - * @param object $pager + * @param int $executionID + * @param int $productID + * @param int $branchID + * @param string|array $builds + * @param string $type + * @param int $param + * @param string $orderBy + * @param string $excludeBugs + * @param object $pager * @access public * @return array */ - public function getExecutionBugs($executionID, $productID = 0, $branchID = 'all', $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null) + public function getExecutionBugs($executionID, $productID = 0, $branchID = 'all', $builds = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null) { $type = strtolower($type); if(strpos($orderBy, 'pri_') !== false) $orderBy = str_replace('pri_', 'priOrder_', $orderBy); @@ -1935,15 +1935,28 @@ class bugModel extends model } else { + $condition = ''; + if($builds) + { + if(!is_array($builds)) $builds = explode(',', $builds); + + $conditions = array(); + foreach($builds as $build) + { + if($build) $conditions[] = "FIND_IN_SET('$build', t1.openedBuild)"; + } + $condition = join(' OR ', $conditions); + $condition = "($condition)"; + } $bugs = $this->dao->select("t1.*, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder, IF(t1.`severity` = 0, {$this->config->maxPriValue}, t1.`severity`) as severityOrder")->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_MODULE)->alias('t2')->on('t1.module=t2.id') ->where('t1.deleted')->eq(0) ->beginIF(!empty($productID) and $branchID !== 'all')->andWhere('t1.branch')->eq($branchID)->fi() - ->beginIF(empty($build))->andWhere('t1.execution')->eq($executionID)->fi() + ->beginIF(empty($builds))->andWhere('t1.execution')->eq($executionID)->fi() ->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID)->fi() ->beginIF($type == 'unresolved')->andWhere('t1.status')->eq('active')->fi() ->beginIF($type == 'noclosed')->andWhere('t1.status')->ne('closed')->fi() - ->beginIF($build)->andWhere("CONCAT(',', t1.openedBuild, ',') like '%,$build,%'")->fi() + ->beginIF($condition)->andWhere("$condition")->fi() ->beginIF(!empty($param))->andWhere('t2.path')->like("%,$param,%")->andWhere('t2.deleted')->eq(0)->fi() ->beginIF($excludeBugs)->andWhere('t1.id')->notIN($excludeBugs)->fi() ->orderBy($orderBy) diff --git a/module/build/control.php b/module/build/control.php index 537ba935d0..8ccca340d5 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -292,7 +292,7 @@ class build extends control $this->view->storyPager = $storyPager; $generatedBugPager = new pager($type == 'generatedBug' ? $recTotal : 0, $recPerPage, $type == 'generatedBug' ? $pageID : 1); - $this->view->generatedBugs = $this->bug->getExecutionBugs($build->execution, $build->product, 'all', $build->id, $type, $param, $type == 'generatedBug' ? $sort : 'status_desc,id_desc', '', $generatedBugPager); + $this->view->generatedBugs = $this->bug->getExecutionBugs($build->execution, $build->product, 'all', "$build->id,{$build->builds}", $type, $param, $type == 'generatedBug' ? $sort : 'status_desc,id_desc', '', $generatedBugPager); $this->view->generatedBugPager = $generatedBugPager; $this->executeHooks($buildID); diff --git a/module/build/lang/de.php b/module/build/lang/de.php index 102f2a399f..39f5f213c7 100644 --- a/module/build/lang/de.php +++ b/module/build/lang/de.php @@ -57,6 +57,7 @@ $lang->build->notice = new stdclass(); $lang->build->notice->changeProduct = "The {$lang->SRCommon}, bug, or the version of the submitted test order has been linked, and its {$lang->productCommon} cannot be modified"; $lang->build->notice->changeExecution = "The version of the submitted test order cannot be modified {$lang->executionCommon}"; $lang->build->notice->changeBuilds = "The version of the submitted test order cannot be modified builds"; +$lang->build->notice->autoRelation = "The completed requirements, resolved bugs, and generated bugs under the relevant version will be automatically associated with the project version"; $lang->build->finishStories = " %s {$lang->SRCommon} sind abgeschlossen."; $lang->build->resolvedBugs = ' %s Bugs sind gelöst.'; diff --git a/module/build/lang/en.php b/module/build/lang/en.php index 2cad705a92..df6d81e8d1 100644 --- a/module/build/lang/en.php +++ b/module/build/lang/en.php @@ -57,6 +57,7 @@ $lang->build->notice = new stdclass(); $lang->build->notice->changeProduct = "The {$lang->SRCommon}, bug, or the version of the submitted test order has been linked, and its {$lang->productCommon} cannot be modified"; $lang->build->notice->changeExecution = "The version of the submitted test order cannot be modified {$lang->executionCommon}"; $lang->build->notice->changeBuilds = "The version of the submitted test order cannot be modified builds"; +$lang->build->notice->autoRelation = "The completed requirements, resolved bugs, and generated bugs under the relevant version will be automatically associated with the project version"; $lang->build->finishStories = " Finished {$lang->SRCommon} %s"; $lang->build->resolvedBugs = ' Resolved Bug %s'; diff --git a/module/build/lang/fr.php b/module/build/lang/fr.php index 5bf136f09b..30ed628f70 100644 --- a/module/build/lang/fr.php +++ b/module/build/lang/fr.php @@ -57,6 +57,7 @@ $lang->build->notice = new stdclass(); $lang->build->notice->changeProduct = "The {$lang->SRCommon}, bug, or the version of the submitted test order has been linked, and its {$lang->productCommon} cannot be modified"; $lang->build->notice->changeExecution = "The version of the submitted test order cannot be modified {$lang->executionCommon}"; $lang->build->notice->changeBuilds = "The version of the submitted test order cannot be modified builds"; +$lang->build->notice->autoRelation = "The completed requirements, resolved bugs, and generated bugs under the relevant version will be automatically associated with the project version"; $lang->build->finishStories = " {$lang->SRCommon} Terminées %s"; $lang->build->resolvedBugs = ' Bugs Résolus %s'; diff --git a/module/build/lang/vi.php b/module/build/lang/vi.php index c5a6f474d1..830fb9234d 100644 --- a/module/build/lang/vi.php +++ b/module/build/lang/vi.php @@ -53,6 +53,7 @@ $lang->build->notice = new stdclass(); $lang->build->notice->changeProduct = "The {$lang->SRCommon}, bug, or the version of the submitted test order has been linked, and its {$lang->productCommon} cannot be modified"; $lang->build->notice->changeExecution = "The version of the submitted test order cannot be modified {$lang->executionCommon}"; $lang->build->notice->changeBuilds = "The version of the submitted test order cannot be modified builds"; +$lang->build->notice->autoRelation = "The completed requirements, resolved bugs, and generated bugs under the relevant version will be automatically associated with the project version"; $lang->build->finishStories = " {$lang->SRCommon} đã kết thúc %s"; $lang->build->resolvedBugs = ' Bug đã giải quyết %s'; diff --git a/module/build/lang/zh-cn.php b/module/build/lang/zh-cn.php index b1bbf9d7ca..0be8d8c8b5 100644 --- a/module/build/lang/zh-cn.php +++ b/module/build/lang/zh-cn.php @@ -57,6 +57,7 @@ $lang->build->notice = new stdclass(); $lang->build->notice->changeProduct = "已经关联{$lang->SRCommon}、Bug或提交测试单的版本,不能修改其所属{$lang->productCommon}"; $lang->build->notice->changeExecution = "提交测试单的版本,不能修改其所属{$lang->executionCommon}"; $lang->build->notice->changeBuilds = "提交测试单的版本,不能修改关联版本"; +$lang->build->notice->autoRelation = "相关版本下完成的需求、解决的Bug、产生的Bug将会自动关联到项目版本中"; $lang->build->finishStories = " 本次共完成 %s 个{$lang->SRCommon}"; $lang->build->resolvedBugs = ' 本次共解决 %s 个Bug'; diff --git a/module/build/model.php b/module/build/model.php index 6a49cfb637..3aa47341da 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -336,6 +336,7 @@ class buildModel extends model ->remove('resolvedBy,allchecker,files,labels,uid') ->get(); + $build = $this->loadModel('file')->processImgURL($build, $this->config->build->editor->create['id'], $this->post->uid); $this->dao->insert(TABLE_BUILD)->data($build) ->autoCheck() @@ -347,6 +348,7 @@ class buildModel extends model if(!dao::isError()) { $buildID = $this->dao->lastInsertID(); + $this->linkChildBuilds($buildID, $build->builds); $this->file->updateObjectID($this->post->uid, $buildID, 'build'); $this->file->saveUpload('build', $buildID); $this->loadModel('score')->create('build', 'create', $buildID); @@ -386,6 +388,8 @@ class buildModel extends model if(isset($build->branch) and $oldBuild->branch != $build->branch) $this->dao->update(TABLE_RELEASE)->set('branch')->eq($build->branch)->where('build')->eq($buildID)->exec(); if(!dao::isError()) { + $addBuilds = array_diff(explode(',', $build->builds), explode(',', $oldBuild->builds)); + if($addBuilds) $this->linkChildBuilds($buildID, $addBuilds); $this->file->updateObjectID($this->post->uid, $buildID, 'build'); return common::createChanges($oldBuild, $build); } @@ -561,6 +565,33 @@ class buildModel extends model foreach($this->post->unlinkBugs as $unlinkBugID) $this->action->create('bug', $unlinkBugID, 'unlinkedfrombuild', '', $buildID); } + /** + * Bugs and stories associated with child builds. + * + * @param int $buildID + * @param string $childBuilds + * @access public + * @return void + */ + public function linkChildBuilds($buildID, $childBuilds) + { + $build = $this->dao->select('bugs, stories')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch(); + $buildList = $this->dao->select('bugs, stories')->from(TABLE_BUILD)->where('id')->in($childBuilds)->fetchAll(); + + foreach($buildList as $buildInfo) + { + if($buildInfo->bugs) $build->bugs .= ",{$buildInfo->bugs}"; + if($buildInfo->stories) $build->stories .= ",{$buildInfo->stories}"; + } + + $build->bugs = explode(',', $build->bugs); + $build->bugs = join(',', array_filter($build->bugs)); + $build->stories = explode(',', $build->stories); + $build->stories = join(',', array_filter($build->stories)); + + $this->dao->update(TABLE_BUILD)->data($build)->where('id')->eq($buildID)->exec(); + } + /** * Build action menu. * diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index 3297178af4..4d50e8e419 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -46,6 +46,7 @@