Permalink
Browse files

code layout

  • Loading branch information...
fmancardi committed Jan 21, 2019
1 parent 006afd4 commit 4d9475bd04d95d450e2a91a713631d19cd387147
Showing with 47 additions and 57 deletions.
  1. +7 −12 lib/functions/execTreeMenu.inc.php
  2. +32 −31 lib/functions/testplan.class.php
  3. +8 −14 lib/functions/treeMenu.inc.php
@@ -550,26 +550,22 @@ function applyStatusFilters($tplan_id,&$items2filter,&$fobj,&$tplan_mgr,$statusC
$methods = $fm['status_code'];
$ffn = array($methods['any_build'] => 'filterStatusSetAtLeastOneOfActiveBuilds',
$methods['all_builds'] => 'filterStatusSetAllActiveBuilds',
$methods['specific_build'] => 'filter_by_status_for_build',
$methods['current_build'] => 'filter_by_status_for_build',
$methods['latest_execution'] => 'filter_by_status_for_latest_execution');
$methods['all_builds'] => 'filterStatusSetAllActiveBuilds',
$methods['specific_build'] => 'filter_by_status_for_build',
$methods['current_build'] => 'filter_by_status_for_build',
$methods['latest_execution'] => 'filter_by_status_for_latest_execution');
$f_method = isset($fobj->filter_result_method) ? $fobj->filter_result_method : null;
$f_result = isset($fobj->filter_result_result) ? $fobj->filter_result_result : null;
$f_result = (array)$f_result;
// die();
// if "any" was selected as filtering status, don't filter by status
if (in_array($statusCfg['all'], $f_result))
{
if (in_array($statusCfg['all'], $f_result)) {
$f_result = null;
return $items2filter; // >>---> Bye!
}
if( ($filter_done = !is_null($f_method) ) )
{
if( ($filter_done = !is_null($f_method) ) ) {
$logMsg = 'FILTER METHOD:' . $f_method . '::' . $ffn[$f_method];
tLog($logMsg,'DEBUG');
@@ -578,8 +574,7 @@ function applyStatusFilters($tplan_id,&$items2filter,&$fobj,&$tplan_mgr,$statusC
// to the build chosen in settings instead of the one in filters
//
// Need to understand why we need to do this 'dirty/brute force initialization'
if ($f_method == $methods['current_build'])
{
if ($f_method == $methods['current_build']) {
$fobj->filter_result_build = $fobj->setting_build;
}
@@ -9,7 +9,7 @@
* @filesource testplan.class.php
* @package TestLink
* @author franciscom
* @copyright 2007-2018, TestLink community
* @copyright 2007-2019, TestLink community
* @link http://testlink.sourceforge.net/
*
**/
@@ -4322,8 +4322,10 @@ function _get_subtree_rec($tplan_id,$node_id,&$pnode,&$itemSet,$filters = null,
*/
function getNotRunAllBuildsForPlatform($id,$platformID,$buildSet=null) {
// On Postgresql
// An output column’s name can be used to refer to the column’s value in ORDER BY and GROUP BY clauses,
// but not in the WHERE or HAVING clauses; there you must write out the expression instead.
// An output column’s name can be used to refer to the column’s value
// in ORDER BY and GROUP BY clauses,
// but not in the WHERE or HAVING clauses; there you must
// write out the expression instead.
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
list($safe_id,$buildsCfg,$sqlLEBBP) = $this->helperGetHits($id,$platformID,$buildSet);
@@ -4882,31 +4884,35 @@ function getHitsSameStatusFullOnPlatform($id,$platformID,$statusSet,$buildSet=nu
*
* If build set is NULL => ON LAST EXECUTION ON ALL ACTIVE builds (full), for a platform
*
* @internal revisions:
* 20120919 - asimon - TICKET 5226: Filtering by test result did not always show the correct matches
*/
function getHitsSameStatusFullALOP($id,$statusSet,$buildSet=null)
{
function getHitsSameStatusFullALOP($id,$statusSet,$buildSet=null,$opt=null) {
// On Postgresql
// An output column’s name can be used to refer to the column’s value in ORDER BY and GROUP BY clauses,
// but not in the WHERE or HAVING clauses; there you must write out the expression instead.
$options = array('onlyActiveBuilds' => true);
$options = array_merge($options,(array)$opt);
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
list($safe_id,$buildsCfg,$sqlLEX) = $this->helperGetHits($id,null,$buildSet,
array('ignorePlatform' => true));
if( $options['onlyActiveBuilds'] ) {
$buildsCfg['statusClause'] = " AND B.active = 1 ";
}
// 20120919 - asimon - TICKET 5226: Filtering by test result did not always show the correct matches
// TICKET 5226: Filtering by test result did not always show the correct matches
// The filtering for "not run" status was simply not implemented for the case
// of not using platforms. Maybe that part was forgotten when refactoring the filters.
// of not using platforms.
// Maybe that part was forgotten when refactoring the filters.
//
// I adopted logic from helperGetHitsSameStatusOnPlatform() to get this working.
//
$flippedStatusSet = array_flip($statusSet); // (code => idx)
$get = array('notRun' => isset($flippedStatusSet[$this->notRunStatusCode]), 'otherStatus' => false);
$hits = array('notRun' => array(), 'otherStatus' => array());
if($get['notRun'])
{
if($get['notRun']) {
$notRunSQL = " /* $debugMsg */ " .
" /* COUNT() is needed as parameter for HAVING clause */ " .
" SELECT COUNT(0) AS COUNTER, NHTCV.parent_id AS tcase_id" .
@@ -5704,8 +5710,7 @@ function helperGetHitsSameStatusOnPlatform($mode,$id,$platformID,$statusSet,$bui
*
*
*/
function helperGetHits($id,$platformID,$buildSet=null,$options=null)
{
function helperGetHits($id,$platformID,$buildSet=null,$options=null) {
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$my['options'] = array('buildID' => 0, 'ignorePlatform' => false, 'ignoreBuild' => false);
$my['options'] = array_merge($my['options'],(array)$options);
@@ -5718,44 +5723,40 @@ function helperGetHits($id,$platformID,$buildSet=null,$options=null)
$buildsCfg['inClause'] = "";
$buildsCfg['count'] = 0;
if($my['options']['buildID'] <= 0)
{
if( is_null($buildSet) )
{
if($my['options']['buildID'] <= 0) {
if( is_null($buildSet) ) {
$buildSet = array_keys($this->get_builds($id, self::ACTIVE_BUILDS));
$buildsCfg['statusClause'] = " AND B.active = 1 ";
}
$buildsCfg['count'] = count($buildSet);
$buildsCfg['inClause'] = implode(",",$buildSet);
}
else
{
} else {
$buildsCfg['inClause'] = intval($my['options']['buildID']);
}
$platformClause = " AND EE.platform_id = " . $safe_id['platform'];
$platformField = " ,EE.platform_id ";
if( $my['options']['ignorePlatform'] )
{
if( $my['options']['ignorePlatform'] ) {
$platformClause = " ";
$platformField = " ";
}
$buildField = " ,EE.build_id ";
if( $my['options']['ignoreBuild'] )
{
if( $my['options']['ignoreBuild'] ) {
$buildField = " ";
}
$sqlLEX = " SELECT EE.tcversion_id,EE.testplan_id {$platformField} {$buildField} ," .
" MAX(EE.id) AS id " .
" FROM {$this->tables['executions']} EE " .
" WHERE EE.testplan_id = " . $safe_id['tplan'] .
" AND EE.build_id IN ({$buildsCfg['inClause']}) " .
$platformClause .
" GROUP BY EE.tcversion_id,EE.testplan_id {$platformField} {$buildField} ";
$sqlLEX = " SELECT EE.tcversion_id,EE.testplan_id
{$platformField} {$buildField} ,
MAX(EE.id) AS id
FROM {$this->tables['executions']} EE
WHERE EE.testplan_id = " . $safe_id['tplan'] .
" AND EE.build_id IN ({$buildsCfg['inClause']})
$platformClause
GROUP BY EE.tcversion_id,EE.testplan_id
{$platformField} {$buildField} ";
return array($safe_id,$buildsCfg,$sqlLEX);
}
@@ -1188,31 +1188,25 @@ function filterStatusSetAtLeastOneOfActiveBuilds(&$tplan_mgr,&$tcase_set,$tplan_
*
* @return array new tcase_set
*/
function filterStatusSetAllActiveBuilds(&$tplan_mgr,&$tcase_set,$tplan_id,$filters)
{
function filterStatusSetAllActiveBuilds(&$tplan_mgr,&$tcase_set,$tplan_id,$filters) {
$buildSet = array_keys($tplan_mgr->get_builds($tplan_id, testplan::ACTIVE_BUILDS));
if( !is_null($buildSet) )
{
if( !is_null($buildSet) ) {
$safe_platform = intval($filters->setting_platform);
if( $safe_platform > 0 )
{
if( $safe_platform > 0 ) {
tLog(basename(__FILE__) . __FUNCTION__ . ':: $tplan_mgr->getHitsSameStatusFullOnPlatform', 'DEBUG');
$hits = $tplan_mgr->getHitsSameStatusFullOnPlatform($tplan_id,$safe_platform,
(array)$filters->filter_result_result,$buildSet);
}
else
{
} else {
tLog(basename(__FILE__) .__FUNCTION__ . ':: $tplan_mgr->getHitsSameStatusFullALOP', 'DEBUG');
$hits = $tplan_mgr->getHitsSameStatusFullALOP($tplan_id,
(array)$filters->filter_result_result,$buildSet);
}
if( is_null($hits) )
{
if( is_null($hits) ) {
$tcase_set = array();
}
else
{
} else {
helper_filter_cleanup($tcase_set,$hits);
unset($hits);
}

0 comments on commit 4d9475b

Please sign in to comment.