* adjust for sync build to release.

This commit is contained in:
王怡栋
2022-11-17 09:40:51 +08:00
parent 0fdbf58dc9
commit 6c0a92fa65
2 changed files with 57 additions and 25 deletions
+49 -24
View File
@@ -1959,21 +1959,17 @@ class bugModel extends model
/**
* Get product left bugs.
*
* @param int $build
* @param int $productID
* @param int $branch
* @param string $linkedBugs
* @param object $pager
* @param int|string $buildIdList
* @param int $productID
* @param int $branch
* @param string $linkedBugs
* @param object $pager
* @access public
* @return array
*/
public function getProductLeftBugs($build, $productID, $branch = '', $linkedBugs = '', $pager = null)
public function getProductLeftBugs($buildIdList, $productID, $branch = '', $linkedBugs = '', $pager = null)
{
$builds = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->in($build)->fetchAll('id');
$executionIdList = array();
foreach($builds as $build) $executionIdList[] = empty($build->execution) ? $build->project : $build->execution;
$executionIdList = array_unique($executionIdList);
$executionIdList = $this->getLinkedExecutionByIdList($buildIdList);
if(empty($executionIdList)) return array();
$executions = $this->dao->select('*')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->fetchAll();
@@ -2072,29 +2068,26 @@ class bugModel extends model
/**
* Get bugs according to buildID and productID.
*
* @param int $buildID
* @param int $productID
* @param string $branch
* @param string $linkedBugs
* @param object $pager
* @param int|string $buildIdList
* @param int $productID
* @param string $branch
* @param string $linkedBugs
* @param object $pager
* @access public
* @return array
*/
public function getReleaseBugs($buildID, $productID, $branch = 0, $linkedBugs = '', $pager = null)
public function getReleaseBugs($buildIdList, $productID, $branch = 0, $linkedBugs = '', $pager = null)
{
$builds = $this->dao->select('id,project,execution')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id');
$executionIdList = array();
foreach($builds as $build) $executionIdList[] = empty($build->execution) ? $build->project : $build->execution;
$executionIdList = array_unique($executionIdList);
$executionIdList = $this->getLinkedExecutionByIdList($buildIdList);
if(empty($executionIdList)) return array();
$executions = $this->dao->select('id,begin')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->fetchAll('id');
$executions = $this->dao->select('id,type,begin')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->fetchAll('id');
$condition = 'execution NOT ' . helper::dbIN($executionIdList);
$minBegin = '';
foreach($executions as $execution)
{
if(empty($minBegin) or $minBegin > $execution->begin) $minBegin = $execution->begin;
$condition .= " OR (execution = '{$execution->id}' AND openedDate < '{$execution->begin}')";
$condition .= " OR (`execution` = '{$execution->id}' AND openedDate < '{$execution->begin}')";
}
$bugs = $this->dao->select('*')->from(TABLE_BUG)
@@ -2107,10 +2100,42 @@ class bugModel extends model
->andWhere('deleted')->eq(0)
->orderBy('openedDate ASC')
->page($pager)
->fetchAll();
->fetchAll('id');
return $bugs;
}
/**
* Get linked execution by build id list.
*
* @param string $buildIdList
* @access public
* @return array
*/
public function getLinkedExecutionByIdList($buildIdList)
{
$builds = $this->dao->select('id,execution')->from(TABLE_BUILD)->where('id')->in($buildIdList)->fetchAll('id');
$executionIdList = array();
$linkedBuildIdList = array();
foreach($builds as $build)
{
if($build->builds) $linkedBuildIdList = array_merge($linkedBuildIdList, explode(',', $build->builds));
if(empty($build->execution)) continue;
$executionIdList[$build->execution] = $build->execution;
}
if($linkedBuildIdList)
{
$linkedBuilds = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->in(array_unique($linkedBuildIdList))->fetchAll('id');
foreach($linkedBuilds as $build)
{
if(empty($build->execution)) continue;
$executionIdList[$build->execution] = $build->execution;
}
}
return $executionIdList;
}
/**
* Get bugs of a story.
*
+8 -1
View File
@@ -168,6 +168,8 @@ class releaseModel extends model
$release = fixer::input('post')
->add('product', (int)$productID)
->add('branch', (int)$branch)
->add('stories', '')
->add('bugs', '')
->setIF($projectID, 'project', $projectID)
->setIF($this->post->build == false, 'build', 0)
->setDefault('stories', '')
@@ -224,7 +226,7 @@ class releaseModel extends model
if($release->build)
{
$builds = $this->dao->select('project, branch, stories, bugs')->from(TABLE_BUILD)->where('id')->in($release->build)->fetchAll();
$builds = $this->dao->select('id,project,branch,stories,bugs')->from(TABLE_BUILD)->where('id')->in($release->build)->fetchAll('id');
foreach($builds as $build)
{
$branches[$build->branch] = $build->branch;
@@ -238,6 +240,11 @@ class releaseModel extends model
if($build->bugs) $release->bugs .= ',' . $build->bugs;
}
}
if($this->post->sync == 'true' and $release->bugs)
{
$releaseBugs = $this->loadModel('bug')->getReleaseBugs(array_keys($builds), $release->product, $release->branch);
$release->bugs = join(',', array_intersect(explode(',', $release->bugs), array_keys($releaseBugs)));
}
$release->build = ',' . trim($release->build, ',') . ',';
$release->branch = ',' . trim(implode(',', $branches), ',') . ',';