diff --git a/db/update18.6.sql b/db/update18.6.sql new file mode 100644 index 0000000000..a3b241e3fb --- /dev/null +++ b/db/update18.6.sql @@ -0,0 +1,183 @@ +ALTER TABLE `zt_doc` ADD `editedList` text NULL AFTER `editingDate`; + +ALTER TABLE `zt_case` ADD INDEX `scene` (`scene`); +UPDATE `zt_case` SET `scene` = `scene` - 100000000 WHERE `scene` > 100000000; +UPDATE `zt_scene` SET `sort` = `sort` - 100000000 WHERE `sort` > 100000000; +UPDATE `zt_scene` SET `parent` = `parent` - 100000000 WHERE `parent` > 100000000; +UPDATE `zt_scene` SET `path` = REPLACE(`path`, ',10000000', ','), `path` = REPLACE(`path`, ',1000000', ','), `path` = REPLACE(`path`, ',100000', ','), `path` = REPLACE(`path`, ',10000', ','); + +-- DROP TABLE IF EXISTS `zt_actionlatest`; +CREATE TABLE IF NOT EXISTS `zt_actionlatest` ( + `id` int(9) unsigned NOT NULL AUTO_INCREMENT, + `objectType` varchar(30) NOT NULL DEFAULT '', + `objectID` mediumint(8) unsigned NOT NULL DEFAULT '0', + `product` text NULL, + `project` mediumint(8) unsigned NOT NULL DEFAULT '0', + `execution` mediumint(8) unsigned NOT NULL DEFAULT '0', + `actor` varchar(100) NOT NULL DEFAULT '', + `action` varchar(80) NOT NULL DEFAULT '', + `date` datetime NULL, + `comment` text NULL, + `extra` text NULL, + `read` enum('0','1') NOT NULL DEFAULT '0', + `vision` varchar(10) NOT NULL DEFAULT 'rnd', + `efforted` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE INDEX `date` ON `zt_actionlatest`(`date`); +CREATE INDEX `actor` ON `zt_actionlatest`(`actor`); +CREATE INDEX `project` ON `zt_actionlatest`(`project`); +CREATE INDEX `action` ON `zt_actionlatest`(`action`); +CREATE INDEX `objectID` ON `zt_actionlatest`(`objectID`); + +INSERT INTO `zt_actionlatest`(`objectType`,`objectID`,`product`,`project`,`execution`,`actor`,`action`,`date`,`comment`,`extra`,`read`,`vision`,`efforted`) +SELECT `objectType`,`objectID`,`product`,`project`,`execution`,`actor`,`action`,`date`,`comment`,`extra`,`read`,`vision`,`efforted` FROM `zt_action` +WHERE `date` >= DATE(DATE_SUB(NOW(), INTERVAL 1 MONTH)); + +INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`) VALUES ('15', '0', '*', '*', '*', 'moduleName=action&methodName=cleanActions', '清除超过一个月的动态', 'zentao', 1, 'normal'); + + +ALTER TABLE `zt_notify` +MODIFY COLUMN `toList` text NOT NULL AFTER `action`, +MODIFY COLUMN `subject` text NOT NULL AFTER `ccList`, +DROP INDEX `objectType_toList_status`, +ADD INDEX `objectType`(`objectType` ASC), +ADD INDEX `status`(`status` ASC); + +CREATE INDEX deleted ON zt_bug (deleted); +CREATE INDEX project ON zt_bug (project); +CREATE INDEX product_status_deleted ON zt_bug (product,status,deleted); + +UPDATE `zt_cron` SET `m` = '*/1' WHERE `command` in ('moduleName=mail&methodName=asyncSend', 'moduleName=webhook&methodName=asyncSend') and `type` = 'zentao'; + +ALTER TABLE `zt_project` ADD INDEX `type_order` (`type`, `order`); + +ALTER TABLE `zt_case` +ADD `bugs` MEDIUMINT NOT NULL DEFAULT '0' AFTER `sort`, +ADD `steps` MEDIUMINT NOT NULL DEFAULT '0' AFTER `bugs`, +ADD `executions` MEDIUMINT NOT NULL DEFAULT '0' AFTER `steps`, +ADD `fails` MEDIUMINT NOT NULL DEFAULT '0' AFTER `executions`; + +ALTER TABLE `zt_testrun` +ADD `taskBugs` MEDIUMINT NOT NULL DEFAULT '0' AFTER `status`, +ADD `taskSteps` MEDIUMINT NOT NULL DEFAULT '0' AFTER `taskBugs`, +ADD `taskExecutions` MEDIUMINT NOT NULL DEFAULT '0' AFTER `taskSteps`, +ADD `taskFails` MEDIUMINT NOT NULL DEFAULT '0' AFTER `taskExecutions`; + +DROP VIEW IF EXISTS `ztv_scenecase`; +CREATE OR REPLACE VIEW `ztv_scenecase` AS SELECT + `zt_case`.`id` AS `id`, + `zt_case`.`title` AS `title`, + `zt_case`.`project` AS `project`, + `zt_case`.`product` AS `product`, + `zt_case`.`execution` AS `execution`, + `zt_case`.`branch` AS `branch`, + `zt_case`.`lib` AS `lib`, + `zt_case`.`module` AS `module`, + `zt_case`.`story` AS `story`, + `zt_case`.`storyVersion` AS `storyVersion`, + `zt_case`.`precondition` AS `precondition`, + `zt_case`.`keywords` AS `keywords`, + `zt_case`.`pri` AS `pri`, + `zt_case`.`type` AS `type`, + `zt_case`.`auto` AS `auto`, + `zt_case`.`frame` AS `frame`, + `zt_case`.`stage` AS `stage`, + `zt_case`.`howRun` AS `howRun`, + `zt_case`.`scriptedBy` AS `scriptedBy`, + `zt_case`.`scriptedDate` AS `scriptedDate`, + `zt_case`.`scriptStatus` AS `scriptStatus`, + `zt_case`.`scriptLocation` AS `scriptLocation`, + `zt_case`.`status` AS `status`, + `zt_case`.`subStatus` AS `subStatus`, + `zt_case`.`color` AS `color`, + `zt_case`.`frequency` AS `frequency`, + IF(`zt_case`.`sort` = 0, `zt_case`.`id`, `zt_case`.`sort`) AS `sort`, + `zt_case`.`openedBy` AS `openedBy`, + `zt_case`.`openedDate` AS `openedDate`, + `zt_case`.`reviewedBy` AS `reviewedBy`, + `zt_case`.`reviewedDate` AS `reviewedDate`, + `zt_case`.`lastEditedBy` AS `lastEditedBy`, + `zt_case`.`lastEditedDate` AS `lastEditedDate`, + `zt_case`.`version` AS `version`, + `zt_case`.`linkCase` AS `linkCase`, + `zt_case`.`fromBug` AS `fromBug`, + `zt_case`.`fromCaseID` AS `fromCaseID`, + `zt_case`.`fromCaseVersion` AS `fromCaseVersion`, + `zt_case`.`deleted` AS `deleted`, + `zt_case`.`lastRunner` AS `lastRunner`, + `zt_case`.`lastRunDate` AS `lastRunDate`, + `zt_case`.`lastRunResult` AS `lastRunResult`, + `zt_case`.`bugs` AS `bugs`, + `zt_case`.`steps` AS `steps`, + `zt_case`.`executions` AS `executions`, + `zt_case`.`fails` AS `fails`, + `zt_case`.`scene` AS `parent`, + `zt_case`.`scene` AS `scene`, + ifnull(`zt_scene`.`grade` + 1 , 1) AS `grade`, + ifnull( + concat( + `zt_scene`.`path`, + `zt_case`.`id`, + ',' + ), + CONVERT( + concat(',' , `zt_case`.`id` , ',') USING utf8 + ) + ) AS `path`, + 1 AS `isCase` +FROM (`zt_case` LEFT JOIN `zt_scene` ON( `zt_case`.`scene` = `zt_scene`.`id`+100000000)) +UNION + SELECT + `zt_scene`.`id`+ 100000000 AS `id`, + `zt_scene`.`title` AS `title`, + 0 AS `project`, + `zt_scene`.`product` AS `product`, + 0 AS `execution`, + `zt_scene`.`branch` AS `branch`, + 0 AS `lib`, + `zt_scene`.`module` AS `module`, + 0 AS `story`, + 0 AS `storyVersion`, + '' AS `precondition`, + '' AS `keywords`, + 0 AS `pri`, + '' AS `type`, + '' AS `auto`, + '' AS `frame`, + '' AS `stage`, + '' AS `howRun`, + '' AS `scriptedBy`, + '' AS `scriptedDate`, + '' AS `scriptStatus`, + '' AS `scriptLocation`, + '' AS `status`, + '' AS `subStatus`, + '' AS `color`, + '' AS `frequency`, + `zt_scene`.`sort` AS `sort`, + `zt_scene`.`openedBy` AS `openedBy`, + `zt_scene`.`openedDate` AS `openedDate`, + '' AS `reviewedBy`, + '' AS `reviewedDate`, + `zt_scene`.`lastEditedBy` AS `lastEditedBy`, + `zt_scene`.`lastEditedDate` AS `lastEditedDate`, + 0 AS `version`, + '' AS `linkCase`, + 0 AS `fromBug`, + 0 AS `fromCaseID`, + '' AS `fromCaseVersion`, + `zt_scene`.`deleted` AS `deleted`, + '' AS `lastRunner`, + '' AS `lastRunDate`, + '' AS `lastRunResult`, + 0 AS `bugs`, + 0 AS `steps`, + 0 AS `executions`, + 0 AS `fails`, + `zt_scene`.`parent` AS `parent`, + `zt_scene`.`parent` AS `scene`, + `zt_scene`.`grade` AS `grade`, + `zt_scene`.`path` AS `path`, + 2 AS `isCase` + FROM `zt_scene`; diff --git a/module/action/model.php b/module/action/model.php index 6c6b98ce05..eb7976ae03 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -90,6 +90,9 @@ class actionModel extends model /* Add index for global search. */ $this->saveIndex($objectType, $objectID, $actionType); + $changeFunc = 'after' . ucfirst($objectType); + if(method_exists($this, $changeFunc)) call_user_func_array(array($this, $changeFunc), array($action, $actionID)); + return $actionID; } @@ -872,6 +875,18 @@ class actionModel extends model return $this->dao->select('objectType')->from(TABLE_ACTION)->where('action')->eq('deleted')->andWhere('extra')->eq($extra)->andWhere('vision')->eq($this->config->vision)->fetchAll('objectType'); } + /** + * Get histories of an action. + * + * @param int $actionID + * @access public + * @return array + */ + public function getHistoryByActionID($actionID) + { + return $this->dao->select('*')->from(TABLE_HISTORY)->where('action')->eq($actionID)->fetchAll(); + } + /** * Get histories of an action. * @@ -907,6 +922,13 @@ class actionModel extends model } $this->dao->insert(TABLE_HISTORY)->data($change)->exec(); } + + if(isset($this->session->calllbackActionList[$actionID])) + { + $callbackMethod = $this->session->calllbackActionList[$actionID]; + unset($this->session->calllbackActionList[$actionID]); + if(method_exists($this, $callbackMethod)) call_user_func_array(array($this, $callbackMethod), array($actionID)); + } } /** @@ -2255,6 +2277,127 @@ class actionModel extends model $this->search->saveIndex($objectType, $data); } + /** + * Trigger to update the field. + * + * @param object $action + * @param int $actionID + * @access public + * @return void + */ + public function afterBug($action, $actionID) + { + if(in_array($action->action, array('opened', 'edited', 'deleted', 'undeleted'))) + { + $bug = $this->dao->select('id,`case`,result')->from(TABLE_BUG)->where('id')->eq($action->objectID)->fetch(); + $caseID = $bug->case; + $resultID = $bug->result; + $this->computeLinkBugs($caseID, $resultID); + $this->session->set('calllbackActionList', array($actionID => 'afterBugCallback')); + } + } + + /** + * Trigger to update the field. + * + * @param int $actionID + * @access public + * @return void + */ + public function afterBugCallback($actionID) + { + $action = $this->getByID($actionID); + $histories = $this->getHistoryByActionID($actionID); + $caseID = 0; + $resultID = 0; + foreach($histories as $history) + { + if($history->field == 'case') $caseID = $history->old; + if($history->field == 'result') $resultID = $history->old; + } + $this->computeLinkBugs($caseID, $resultID); + } + + /** + * Count the number of bugs associated with a case. + * + * @param int $caseID + * @param int $resultID + * @access public + * @return void + */ + public function computeLinkBugs($caseID, $resultID) + { + if($caseID) + { + $bugs = $this->dao->select('count(*) as count')->from(TABLE_BUG)->where('`case`')->eq($caseID)->andWhere('deleted')->eq('0')->fetch('count'); + $bugs = $bugs ? $bugs : 0; + $this->dao->update(TABLE_CASE)->set('bugs')->eq($bugs)->where('id')->eq($caseID)->exec(); + } + + $testRun = $this->dao->select('id,task,`case`')->from(TABLE_TESTRUN)->where('id')->eq($resultID)->fetch(); + if(!empty($testRun)) + { + $taskBugs = $this->dao->select('count(*) as count')->from(TABLE_BUG)->where('result')->eq($resultID)->andWhere('`case`')->eq($caseID)->andWhere('deleted')->eq('0')->fetch('count'); + $taskBugs = $taskBugs ? $taskBugs : 0; + $this->dao->update(TABLE_TESTRUN)->set('taskBugs')->eq($taskBugs)->where('id')->eq($resultID)->exec(); + } + } + + /** + * Trigger to update the field. + * + * @param object $action + * @param int $actionID + * @access public + * @return void + */ + public function afterCase($action) + { + $objectID = $action->objectID; + if(in_array($action->action, array('opened', 'edited', 'deleted', 'undeleted', 'linked2testtask', 'unlinkedfromtesttask'))) + { + $case = $this->dao->select('id,version')->from(TABLE_CASE)->where('id')->eq($objectID)->fetch(); + $steps = $this->dao->select('count(*) as count')->from(TABLE_CASESTEP)->where('`case`')->eq($objectID)->andWhere('version')->eq($case->version)->fetch('count'); + $steps = $steps ? $steps : 0; + $this->dao->update(TABLE_CASE)->set('steps')->eq($steps)->where('id')->eq($objectID)->exec(); + + $testrunList = $this->dao->select('*')->from(TABLE_TESTRUN)->where('`case`')->eq($objectID)->fetchAll(); + foreach($testrunList as $testrun) + { + $taskSteps = $this->dao->select('count(distinct t1.id) as count')->from(TABLE_CASESTEP)->alias('t1') + ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.`case`=t2.`case`') + ->where('t2.id')->eq($testrun->id) + ->andWhere('t1.`case`')->eq($testrun->case) + ->andWhere('t1.type')->ne('group') + ->andWhere('t1.version=t2.version') + ->fetch('count'); + + $taskSteps = $taskSteps ? $taskSteps : 0; + $this->dao->update(TABLE_TESTRUN)->set('taskSteps')->eq($taskSteps)->where('id')->eq($testrun->id)->exec(); + } + } + + if($action->action == 'run') + { + $executions = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->where('`case`')->eq($objectID)->fetch('count'); + $fails = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->where('`case`')->eq($objectID)->andWhere('caseResult')->eq('fail')->fetch('count'); + $executions = $executions ? $executions : 0; + $fails = $fails ? $fails : 0; + $this->dao->update(TABLE_CASE)->set('executions')->eq($executions)->set('fails')->eq($fails)->where('id')->eq($objectID)->exec(); + + $testrunList = $this->dao->select('*')->from(TABLE_TESTRUN)->where('`case`')->eq($objectID)->fetchAll(); + foreach($testrunList as $testrun) + { + $taskExecutions = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->where('`run`')->eq($testrun->id)->fetch('count'); + $taskFails = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->where('`run`')->eq($testrun->id)->andWhere('caseResult')->eq('fail')->fetch('count'); + $taskExecutions = $taskExecutions ? $taskExecutions : 0; + $taskFails = $taskFails ? $taskFails : 0; + $this->dao->update(TABLE_TESTRUN)->set('taskExecutions')->eq($taskExecutions)->set('taskFails')->eq($taskFails)->where('id')->eq($testrun->id)->exec(); + } + } + } + /** * Print actions of an object for API(JIHU). * diff --git a/module/execution/control.php b/module/execution/control.php index c36932cd50..a02fbd0404 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1220,7 +1220,6 @@ class execution extends control $cases = $this->loadModel('testcase')->getExecutionCases($executionID, $productID, $branchID, $moduleID, $orderBy, $pager, $type); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); - $cases = $this->testcase->appendData($cases, 'case'); $cases = $this->loadModel('story')->checkNeedConfirm($cases); $modules = $this->tree->getAllModulePairs('case'); diff --git a/module/job/control.php b/module/job/control.php index 887a53e845..5a19fe8b7d 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -279,7 +279,6 @@ class job extends control $runs = $this->testtask->getRuns($taskID, 0, 'id'); $cases = array(); - $runs = $this->loadModel('testcase')->appendData($runs, 'testrun'); foreach($runs as $run) $cases[$run->case] = $run; $results = $this->dao->select('*')->from(TABLE_TESTRESULT)->where('`case`')->in(array_keys($cases))->andWhere('run')->in(array_keys($runs))->fetchAll('run'); diff --git a/module/my/control.php b/module/my/control.php index 6062f97f31..0f38e29924 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -690,7 +690,6 @@ EOF; $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); $cases = $this->loadModel('story')->checkNeedConfirm($cases); - $cases = $this->testcase->appendData($cases, $type == 'assigntome' ? 'run' : 'case'); /* Build the search form. */ $currentMethod = $this->app->rawMethod; diff --git a/module/testcase/control.php b/module/testcase/control.php index 45e6d426d3..c41123365c 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -208,7 +208,6 @@ class testcase extends control /* Process case for check story changed. */ $cases = $this->loadModel('story')->checkNeedConfirm($cases); - $cases = $this->testcase->appendData($cases); foreach($cases as $case) { $case->parent = 0; @@ -217,6 +216,8 @@ class testcase extends control $case->isScene = false; } + $scenes = $this->loadModel('story')->checkNeedConfirm($scenes); + /* Build the search form. */ $currentModule = $this->app->tab == 'project' ? 'project' : 'testcase'; $currentMethod = $this->app->tab == 'project' ? 'testcase' : 'browse'; @@ -327,7 +328,6 @@ class testcase extends control $cases = $this->testcase->getModuleCases($productID, $branch, 0, '', 'no', $caseType, $groupBy); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); $cases = $this->loadModel('story')->checkNeedConfirm($cases); - $cases = $this->testcase->appendData($cases); $groupCases = array(); $groupByList = array(); @@ -1812,7 +1812,6 @@ class testcase extends control $relatedFiles = $this->dao->select('id, objectID, pathname, title')->from(TABLE_FILE)->where('objectType')->eq('testcase')->andWhere('objectID')->in(@array_keys($cases))->andWhere('extra')->ne('editor')->fetchGroup('objectID'); $relatedScenes = $this->testcase->getSceneMenu($productID, 0); - $cases = $this->testcase->appendData($cases); foreach($cases as $case) { $case->stepDesc = ''; @@ -1880,9 +1879,9 @@ class testcase extends control if(isset($users[$case->lastRunner])) $case->lastRunner = $users[$case->lastRunner]; if(isset($caseLang->resultList[$case->lastRunResult])) $case->lastRunResult = $caseLang->resultList[$case->lastRunResult]; - $case->bugsAB = $case->bugs; unset($case->bugs); - $case->resultsAB = $case->results; unset($case->results); - $case->stepNumberAB = $case->stepNumber; unset($case->stepNumber); + $case->bugsAB = $taskID ? $case->taskBugs : $case->bugs; + $case->resultsAB = $taskID ? $case->taskExecutions : $case->executions; + $case->stepNumberAB = $taskID ? $case->taskSteps : $case->steps; unset($case->caseFails); $case->stage = explode(',', $case->stage); diff --git a/module/testcase/model.php b/module/testcase/model.php index 9ba4fb5584..4155308d52 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -683,7 +683,7 @@ class testcaseModel extends model */ public function getByAssignedTo($account, $orderBy = 'id_desc', $pager = null, $auto = 'no') { - return $this->dao->select('t1.id as run, t1.task,t1.case,t1.version,t1.assignedTo,t1.lastRunner,t1.lastRunDate,t1.lastRunResult,t1.status as lastRunStatus,t2.id as id,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t2.story,t2.storyVersion,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1') + return $this->dao->select('t1.id as run, t1.task,t1.case,t1.version,t1.assignedTo,t1.lastRunner,t1.lastRunDate,t1.lastRunResult,t1.status as lastRunStatus,t1.taskFails as fails,t2.id as id,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t2.story,t2.storyVersion,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->leftJoin(TABLE_TESTTASK)->alias('t3')->on('t1.task = t3.id') ->where('t1.assignedTo')->eq($account) @@ -747,7 +747,7 @@ class testcaseModel extends model ->andWhere('t1.deleted')->eq('0') ->orderBy($orderBy)->page($pager) ->fetchAll('id'); - return $this->appendData($cases); + return $cases; } /** @@ -1545,7 +1545,7 @@ class testcaseModel extends model $action = strtolower($action); - if($module == 'testcase' && $action == 'createbug') return $case->caseFails > 0; + if($module == 'testcase' && $action == 'createbug') return $case->fails > 0; if($module == 'testcase' && $action == 'review') return isset($case->caseStatus) ? $case->caseStatus == 'wait' : $case->status == 'wait'; return true; @@ -2288,7 +2288,9 @@ class testcaseModel extends model $class .= $case->status; $title = "title='" . $this->processStatus('testcase', $case) . "'"; } - if(strpos(',bugs,results,stepNumber,', ",$id,") !== false) $title = "title='{$case->$id}'"; + if($id == 'bugs') $title = "title='{$case->$id}'"; + if($id == 'results') $title = "title='{$case->executions}'"; + if($id == 'stepNumber') $title = "title='{$case->steps}'"; if($id == 'actions') $class .= ' c-actions'; if($id == 'lastRunResult') $class .= " {$case->lastRunResult}"; if(strpos(',stage,precondition,keywords,story,', ",{$id},") !== false) $class .= ' text-ellipsis'; @@ -2454,10 +2456,10 @@ class testcaseModel extends model if(!$isScene) echo (common::hasPriv('testcase', 'bugs') and $case->bugs) ? html::a(helper::createLink('testcase', 'bugs', "runID=0&caseID={$case->id}"), $case->bugs, '', "class='iframe'") : $case->bugs; break; case 'results': - if(!$isScene) echo (common::hasPriv('testtask', 'results') and $case->results) ? html::a(helper::createLink('testtask', 'results', "runID=0&caseID={$case->id}"), $case->results, '', "class='iframe'") : $case->results; + if (!$isScene) echo (common::hasPriv('testtask', 'results') and $case->executions) ? html::a(helper::createLink('testtask', 'results', "runID=0&caseID={$case->id}"), $case->executions, '', "class='iframe'") : $case->executions; break; case 'stepNumber': - if(!$isScene) echo $case->stepNumber; + if (!$isScene) echo $case->steps; break; case 'actions': if(!$isScene) @@ -2475,69 +2477,6 @@ class testcaseModel extends model } } - /** - * Append bugs and results. - * - * @param int $cases - * @param string $type - * @param array $caseIdlist - * @access public - * @return void - */ - public function appendData($cases, $type = 'case', $caseIdlist = array()) - { - if(empty($caseIdlist)) $caseIdList = array_keys($cases); - if($type == 'case') - { - $caseBugs = $this->dao->select('count(*) as count, `case`')->from(TABLE_BUG)->where('`case`')->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count'); - $results = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT)->where('`case`')->in($caseIdList)->groupBy('`case`')->fetchPairs('case', 'count'); - - $caseFails = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT) - ->where('caseResult')->eq('fail') - ->andwhere('`case`')->in($caseIdList) - ->groupBy('`case`') - ->fetchPairs('case','count'); - - $steps = $this->dao->select('count(distinct t1.id) as count, t1.`case`')->from(TABLE_CASESTEP)->alias('t1') - ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.`case`=t2.`id`') - ->where('t1.`case`')->in($caseIdList) - ->andWhere('t1.type')->ne('group') - ->andWhere('t1.version=t2.version') - ->groupBy('t1.`case`') - ->fetchPairs('case', 'count'); - } - else - { - $caseBugs = $this->dao->select('count(*) as count, `case`')->from(TABLE_BUG)->where('`result`')->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count'); - $results = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT)->where('`run`')->in($caseIdList)->groupBy('`case`')->fetchPairs('case', 'count'); - - $caseFails = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT) - ->where('caseResult')->eq('fail') - ->andwhere('`run`')->in($caseIdList) - ->groupBy('`case`') - ->fetchPairs('case','count'); - - $steps = $this->dao->select('count(distinct t1.id) as count, t1.`case`')->from(TABLE_CASESTEP)->alias('t1') - ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.`case`=t2.`case`') - ->where('t2.`id`')->in($caseIdList) - ->andWhere('t1.type')->ne('group') - ->andWhere('t1.version=t2.version') - ->groupBy('t1.`case`') - ->fetchPairs('case', 'count'); - } - - foreach($cases as $key => $case) - { - $caseID = $type == 'case' ? $case->id : $case->case; - $case->bugs = isset($caseBugs[$caseID]) ? $caseBugs[$caseID] : 0; - $case->results = isset($results[$caseID]) ? $results[$caseID] : 0; - $case->caseFails = isset($caseFails[$caseID]) ? $caseFails[$caseID] : 0; - $case->stepNumber = isset($steps[$caseID]) ? $steps[$caseID] : 0; - } - - return $cases; - } - /** * Check whether force not review. * diff --git a/module/testcase/view/groupcase.html.php b/module/testcase/view/groupcase.html.php index 7908bbaa94..560cce210a 100644 --- a/module/testcase/view/groupcase.html.php +++ b/module/testcase/view/groupcase.html.php @@ -88,8 +88,8 @@ ?>