* Finisht task #8497.
This commit is contained in:
+59
-9
@@ -50,22 +50,22 @@ class buildModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get builds of a project.
|
||||
* Get builds of a execution.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $executionID
|
||||
* @param string $type all|product|bysearch
|
||||
* @param int|string $param productID|buildQuery
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectBuilds($projectID, $type = '', $param = '')
|
||||
public function getExecutionBuilds($executionID, $type = '', $param = '')
|
||||
{
|
||||
return $this->dao->select('t1.*, t2.name as projectName, t3.name as productName, t4.name as branchName')
|
||||
->from(TABLE_BUILD)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id')
|
||||
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->where('t1.project')->eq((int)$executionID)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->beginIF($type == 'product' and $param)->andWhere('t1.product')->eq($param)->fi()
|
||||
->beginIF($type == 'bysearch')->andWhere($param)->fi()
|
||||
@@ -74,14 +74,14 @@ class buildModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get builds of a project by search.
|
||||
* Get builds of a execution by search.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $executionID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectBuildsBySearch($projectID, $queryID)
|
||||
public function getExecutionBuildsBySearch($executionID, $queryID)
|
||||
{
|
||||
/* If there are saved query conditions, reset the session. */
|
||||
if($queryID)
|
||||
@@ -104,7 +104,7 @@ class buildModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getProjectBuilds($projectID, 'bysearch', $buildQuery);
|
||||
return $this->getExecutionBuilds($executionID, 'bysearch', $buildQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,9 @@ class buildModel extends model
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $params noempty|notrunk, can be a set of them
|
||||
* @param int $buildID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -128,7 +130,55 @@ class buildModel extends model
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
|
||||
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
|
||||
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->where('t1.PRJ')->eq((int)$projectID)
|
||||
->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi()
|
||||
->beginIF($branch)->andWhere('t1.branch')->in("0,$branch")->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy('t1.date desc, t1.id desc')->fetchAll('id');
|
||||
|
||||
/* Set builds and filter terminate releases. */
|
||||
$builds = array();
|
||||
foreach($projectBuilds as $buildID => $build)
|
||||
{
|
||||
if(empty($build->releaseID) and (strpos($params, 'nodone') !== false) and ($build->projectStatus === 'done')) continue;
|
||||
if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue;
|
||||
$builds[$buildID] = $build->name;
|
||||
}
|
||||
if(!$builds) return $sysBuilds + $selectedBuilds;
|
||||
|
||||
/* if the build has been released, replace build name with release name. */
|
||||
$releases = $this->dao->select('build, name')->from(TABLE_RELEASE)
|
||||
->where('build')->in(array_keys($builds))
|
||||
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchPairs();
|
||||
foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName;
|
||||
|
||||
return $sysBuilds + $builds + $selectedBuilds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get builds of a execution in pairs.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param int $productID
|
||||
* @param string $params noempty|notrunk, can be a set of them
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getExecutionBuildPairs($executionID, $productID, $branch = 0, $params = '', $buildID = 0)
|
||||
{
|
||||
$sysBuilds = array();
|
||||
$selectedBuilds = array();
|
||||
if(strpos($params, 'noempty') === false) $sysBuilds = array('' => '');
|
||||
if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => $this->lang->trunk);
|
||||
if($buildID != 0) $selectedBuilds = $this->dao->select('id, name')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchPairs();
|
||||
|
||||
$projectBuilds = $this->dao->select('t1.id, t1.name, t1.project, t2.status as projectStatus, t3.id as releaseID, t3.status as releaseStatus, t4.name as branchName')->from(TABLE_BUILD)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
|
||||
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
|
||||
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
|
||||
->where('t1.project')->eq((int)$executionID)
|
||||
->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi()
|
||||
->beginIF($branch)->andWhere('t1.branch')->in("0,$branch")->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
|
||||
Reference in New Issue
Block a user