* finish task #6649.
This commit is contained in:
@@ -581,6 +581,96 @@ class testtaskModel extends model
|
||||
return $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bug info.
|
||||
*
|
||||
* @param int $taskID
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getBugInfo($taskID, $productID)
|
||||
{
|
||||
$foundBugs = $this->dao->select('*')->from(TABLE_BUG)->where('product')->in($productID)->andWhere('testtask')->eq($taskID)->andWhere('deleted')->eq(0)->fetchAll();
|
||||
|
||||
$severityGroups = $statusGroups = $openedByGroups = $resolvedByGroups = $resolutionGroups = $moduleGroups = array();
|
||||
$resolvedBugs = 0;
|
||||
foreach($foundBugs as $bug)
|
||||
{
|
||||
$severityGroups[$bug->severity] = isset($severityGroups[$bug->severity]) ? $severityGroups[$bug->severity] + 1 : 1;
|
||||
$statusGroups[$bug->status] = isset($statusGroups[$bug->status]) ? $statusGroups[$bug->status] + 1 : 1;
|
||||
$openedByGroups[$bug->openedBy] = isset($openedByGroups[$bug->openedBy]) ? $openedByGroups[$bug->openedBy] + 1 : 1;
|
||||
$moduleGroups[$bug->module] = isset($moduleGroups[$bug->module]) ? $moduleGroups[$bug->module] + 1 : 1;
|
||||
|
||||
if($bug->resolvedBy) $resolvedByGroups[$bug->resolvedBy] = isset($resolvedByGroups[$bug->resolvedBy]) ? $resolvedByGroups[$bug->resolvedBy] + 1 : 1;
|
||||
if($bug->resolution) $resolutionGroups[$bug->resolution] = isset($resolutionGroups[$bug->resolution]) ? $resolutionGroups[$bug->resolution] + 1 : 1;
|
||||
if($bug->status == 'resolved' or $bug->status == 'closed') $resolvedBugs ++;
|
||||
}
|
||||
|
||||
$bugInfo['bugConfirmedRate'] = empty($resolvedBugs) ? 0 : round((zget($resolutionGroups, 'fixed', 0) + zget($resolutionGroups, 'postponed', 0)) / $resolvedBugs * 100, 2);
|
||||
$bugInfo['bugCreateByCaseRate'] = empty($byCaseNum) ? 0 : round($byCaseNum / count($foundBugs) * 100, 2);
|
||||
|
||||
$this->app->loadLang('bug');
|
||||
$users = $this->loadModel('user')->getPairs('noclosed|noletter|nodeleted');
|
||||
$data = array();
|
||||
foreach($severityGroups as $severity => $count)
|
||||
{
|
||||
$data[$severity] = new stdclass();
|
||||
$data[$severity]->name = zget($this->lang->bug->severityList, $severity);
|
||||
$data[$severity]->value = $count;
|
||||
}
|
||||
$bugInfo['bugSeverityGroups'] = $data;
|
||||
|
||||
$data = array();
|
||||
foreach($statusGroups as $status => $count)
|
||||
{
|
||||
$data[$status] = new stdclass();
|
||||
$data[$status]->name = zget($this->lang->bug->statusList, $status);
|
||||
$data[$status]->value = $count;
|
||||
}
|
||||
$bugInfo['bugStatusGroups'] = $data;
|
||||
|
||||
$data = array();
|
||||
foreach($resolutionGroups as $resolution => $count)
|
||||
{
|
||||
$data[$resolution] = new stdclass();
|
||||
$data[$resolution]->name = zget($this->lang->bug->resolutionList, $resolution);
|
||||
$data[$resolution]->value = $count;
|
||||
}
|
||||
$bugInfo['bugResolutionGroups'] = $data;
|
||||
|
||||
$data = array();
|
||||
foreach($openedByGroups as $openedBy => $count)
|
||||
{
|
||||
$data[$openedBy] = new stdclass();
|
||||
$data[$openedBy]->name = zget($users, $openedBy);
|
||||
$data[$openedBy]->value = $count;
|
||||
}
|
||||
$bugInfo['bugOpenedByGroups'] = $data;
|
||||
|
||||
$this->loadModel('tree');
|
||||
$modules = $this->tree->getOptionMenu($productID, $viewType = 'bug');
|
||||
$data = array();
|
||||
foreach($moduleGroups as $moduleID => $count)
|
||||
{
|
||||
$data[$moduleID] = new stdclass();
|
||||
$data[$moduleID]->name = zget($modules, $moduleID);
|
||||
$data[$moduleID]->value = $count;
|
||||
}
|
||||
$bugInfo['bugModuleGroups'] = $data;
|
||||
|
||||
$data = array();
|
||||
foreach($resolvedByGroups as $resolvedBy => $count)
|
||||
{
|
||||
$data[$resolvedBy] = new stdclass();
|
||||
$data[$resolvedBy]->name = zget($users, $resolvedBy);
|
||||
$data[$resolvedBy]->value = $count;
|
||||
}
|
||||
$bugInfo['bugResolvedByGroups'] = $data;
|
||||
|
||||
return $bugInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the default chart settings and the settings of current chart.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user