* add testtask repot for bug report.

This commit is contained in:
wangyidong
2017-03-22 11:31:14 +08:00
parent 6e5dbf8d84
commit 5b2c5c80ba
16 changed files with 118 additions and 49 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<li>
<div class='label-angle<?php if(!empty($moduleID)) echo ' with-close';?>'>
<?php
echo isset($moduleID) ? $moduleName : $this->lang->tree->all;
echo !empty($moduleID) ? $moduleName : $this->lang->tree->all;
if(!empty($moduleID))
{
$removeLink = $browseType == 'bymodule' ? inlink('browse', "productID=$productID&branch=$branch&browseType=$browseType&param=0&orderBy=$orderBy&recTotal=0&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("caseModule")';
-10
View File
@@ -178,8 +178,6 @@ class testreport extends control
}
$cases = $this->testreport->getTaskCases($tasks);
$bugInfo = $this->testreport->getBugInfo($tasks, $productIdList, $begin, $end, $builds);
$modules = array();
foreach($productIdList as $productID) $modules += $this->tree->getOptionMenu($productID, $viewType = 'bug');
$this->view->begin = $begin;
@@ -196,7 +194,6 @@ class testreport extends control
$this->view->builds = $builds;
$this->view->users = $this->user->getPairs('noletter|nodeleted|noclosed');
$this->view->modules = $modules;
$this->view->cases = $cases;
$this->view->caseSummary = $this->testreport->getResultSummary($tasks, $cases);
@@ -289,8 +286,6 @@ class testreport extends control
$cases = $this->testreport->getTaskCases($tasks);
$bugInfo = $this->testreport->getBugInfo($tasks, $productIdList, $report->begin, $report->end, $builds);
$modules = array();
foreach($productIdList as $productID) $modules += $this->tree->getOptionMenu($productID, $viewType = 'bug');
$this->view->title = $report->title . $this->lang->testreport->edit;
@@ -304,7 +299,6 @@ class testreport extends control
$this->view->builds = $builds;
$this->view->users = $this->user->getPairs('noletter|nodeleted|noclosed');
$this->view->modules = $modules;
$this->view->cases = $cases;
$this->view->caseSummary = $this->testreport->getResultSummary($tasks, $cases);
@@ -343,7 +337,6 @@ class testreport extends control
$browseLink = inlink('browse', "objectID=$projectID&objectType=project");
$this->view->position[] = html::a($browseLink, $project->name);
}
$stories = $report->stories ? $this->story->getByList($report->stories) : array();
@@ -360,8 +353,6 @@ class testreport extends control
$builds = $report->builds ? $this->build->getByList($report->builds) : array();
$cases = $this->testreport->getTaskCases($tasks, $report->cases);
$bugInfo = $this->testreport->getBugInfo($tasks, $report->product, $report->begin, $report->end, $builds);
$modules = array();
foreach(explode(',', $report->product) as $productID) $modules += $this->tree->getOptionMenu($productID, $viewType = 'bug');
$this->view->title = $report->title;
$this->view->browseLink = $browseLink;
@@ -374,7 +365,6 @@ class testreport extends control
$this->view->builds = $builds;
$this->view->cases = $cases;
$this->view->users = $this->user->getPairs('noletter|nodeleted|noclosed');
$this->view->modules = $modules;
$this->view->actions = $this->loadModel('action')->getList('testreport', $reportID);
$this->view->storySummary = $this->product->summary($stories);
+65 -8
View File
@@ -152,8 +152,8 @@ class testreportModel extends model
$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->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 ++;
}
@@ -166,16 +166,73 @@ class testreportModel extends model
if(!array_diff(explode(',', $bug->openedBuild), $buildIdList) and ($bug->status == 'active' OR $bug->resolvedDate > "$end 23:59:59")) $legacyBugs[$bug->id] = $bug;
if($bug->case) $byCaseNum ++;
}
$bugInfo['legacyBugs'] = $legacyBugs;
$bugInfo['countBugByTask'] = count($bugsByTask);
$bugInfo['bugSeverityGroups'] = $severityGroups;
$bugInfo['bugStatusGroups'] = $statusGroups;
$bugInfo['bugResolutionGroups'] = $resolutionGroups;
$bugInfo['bugOpenedByGroups'] = $openedByGroups;
$bugInfo['bugModuleGroups'] = $moduleGroups;
$bugInfo['bugResolvedByGroups'] = $resolvedByGroups;
$bugInfo['bugConfirmedRate'] = empty($resolvedBugs) ? 0 : round((count(zget($resolutionGroups, 'fixed', array())) + count(zget($resolutionGroups, 'postponed', array()))) / $resolvedBugs * 100, 2);
$bugInfo['bugCreateByCaseRate'] = empty($byCaseNum) ? 0 : round($byCaseNum / count($newBugs) * 100, 2);
$this->app->loadLang('bug');
$users = $this->loadModel('user')->getPairs('noclosed|nodeleted|noletter');
$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 = array();
$data = array();
if(is_string($productIdList)) $productIdList = explode(',', $productIdList);
foreach($productIdList as $productID) $modules += $this->tree->getOptionMenu($productID, $viewType = 'bug');
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;
}
@@ -4,9 +4,8 @@
<?php if(($row % 1) == 0) echo '<tr>';?>
<?php $row++;?>
<td class='text-top'>
<?php $sum = array_sum($infoValue);?>
<table class='table table-condensed table-report' id='bugSeverityGroups'>
<?php if($sum == 0):?>
<?php if(empty($infoValue)):?>
<tr>
<td class='none-data'>
<h5><?php echo $lang->testreport->$infoKey?></h5>
@@ -14,6 +13,7 @@
</td>
</tr>
<?php else:?>
<?php $sum = 0; foreach($infoValue as $value) $sum += $value->value;?>
<tr class='text-top'>
<td class='w-p70'>
<div class='chart-wrapper text-center'>
@@ -46,10 +46,12 @@
<?php foreach($list as $listKey => $listValue):?>
<?php
$label = $listValue;
if($infoKey == 'bugOpenedByGroups' or $infoKey == 'bugResolvedByGroups') $label = zget($users, $listKey);
if($infoKey == 'bugModuleGroups') $label = zget($modules, $listKey);
if(empty($label)) continue;
$data = zget($infoValue, $listKey, 0);
$data = 0;
if(isset($infoValue[$listKey]))
{
$label = $infoValue[$listKey]->name;
$data = $infoValue[$listKey]->value;
}
?>
<tr class='text-center'>
<td class='chart-color w-20px'><i class='chart-color-dot icon-circle'></i></td>
+1 -1
View File
@@ -25,6 +25,6 @@
<?php endforeach;?>
</tbody>
<?php else:?>
<tr><td class='none-data'><?php echo $lang->testreport->none;?></td></tr>
<tr><td class='none-data' colspan='7'><?php echo $lang->testreport->none;?></td></tr>
<?php endif?>
</table>
+1 -1
View File
@@ -19,6 +19,6 @@
<?php endforeach;?>
</tbody>
<?php else:?>
<tr><td class='none-data'><?php echo 'Trunk'?></td></tr>
<tr><td class='none-data' colspan='4'><?php echo 'Trunk'?></td></tr>
<?php endif;?>
</table>
+1 -1
View File
@@ -29,6 +29,6 @@
<?php endforeach;?>
</tbody>
<?php else:?>
<tr><td class='none-data'><?php echo $lang->testreport->none;?></td></tr>
<tr><td class='none-data' colspan='9'><?php echo $lang->testreport->none;?></td></tr>
<?php endif;?>
</table>
@@ -5,7 +5,7 @@
<th class='w-pri'> <?php echo $lang->priAB;?></th>
<th> <?php echo $lang->bug->title;?></th>
<th class='w-user'> <?php echo $lang->openedByAB;?></th>
<th class='w-user'><?php echo $lang->bug->resolvedBy;?></th>
<th class='w-user'> <?php echo $lang->bug->resolvedBy;?></th>
<th class='w-130px'><?php echo $lang->bug->resolvedDate;?></th>
<th class='w-80px'> <?php echo $lang->statusAB;?></th>
</tr>
@@ -25,6 +25,6 @@
<?php endforeach;?>
</tbody>
<?php else:?>
<tr><td class='none-data'><?php echo $lang->testreport->none;?></td></tr>
<tr><td class='none-data' colspan='7'><?php echo $lang->testreport->none;?></td></tr>
<?php endif?>
</table>
+1 -1
View File
@@ -27,6 +27,6 @@
<?php endforeach;?>
</tbody>
<?php else:?>
<tr><td class='none-data'><?php echo $lang->testreport->none;?></td></tr>
<tr><td class='none-data' colspan='8'><?php echo $lang->testreport->none;?></td></tr>
<?php endif?>
</table>
+5 -4
View File
@@ -311,16 +311,17 @@ class testtask extends control
public function report($productID, $taskID, $browseType, $branchID, $moduleID)
{
$this->loadModel('report');
$this->view->charts = array();
$this->view->charts = array();
if(!empty($_POST))
{
$task = $this->testtask->getById($taskID);
$bugInfo = $this->loadModel('testreport')->getBugInfo(array($taskID => $taskID), array($productID => $productID), $task->begin, $task->end, array($task->build => $task->build));
foreach($this->post->charts as $chart)
{
$chartFunc = 'getDataOf' . $chart;
$chartData = $this->testtask->$chartFunc($taskID);
$chartOption = $this->lang->testtask->report->$chart;
$this->testtask->mergeChartOption($chart);
$chartData = isset($bugInfo[$chart]) ? $bugInfo[$chart] : $this->testtask->$chartFunc($taskID);
$chartOption = $this->testtask->mergeChartOption($chart);
$this->view->charts[$chart] = $chartOption;
$this->view->datas[$chart] = $this->report->computePercent($chartData);
+7
View File
@@ -0,0 +1,7 @@
.table-bordered caption {border: 1px solid #ddd;}
.table-bordered tr > th:first-child, .table-bordered tr > td:first-child {border-left: 1px solid #ddd!important}
.table-bordered tr > th:last-child, .table-bordered tr > td:last-child {border-right: 1px solid #ddd!important}
.col-side {width: 250px}
.panel-heading > strong > span {float: right; color: #29a8cd;}
+14
View File
@@ -0,0 +1,14 @@
$(function()
{
var resizeChartTable = function()
{
$('.table-wrapper').each(function()
{
var $this = $(this);
$this.css('max-height', $this.closest('.table').find('.chart-wrapper').outerHeight());
});
};
resizeChartTable();
fixedTableHead('.table-wrapper');
$(window).resize(resizeChartTable);
});
+7 -11
View File
@@ -59,7 +59,7 @@ $lang->testtask->linkVersion = '版本';
$lang->testtask->lastRunAccount = '执行人';
$lang->testtask->lastRunTime = '执行时间';
$lang->testtask->lastRunResult = '结果';
$lang->testtask->report = '测试总结';
$lang->testtask->reportField = '测试总结';
$lang->testtask->files = '上传附件';
$lang->testtask->legendDesc = '版本描述';
@@ -143,19 +143,15 @@ $lang->testtask->report->charts['testTaskPerRunResult'] = '用例结果统计';
$lang->testtask->report->charts['testTaskPerType'] = '用例类型统计';
$lang->testtask->report->charts['testTaskPerModule'] = '用例模块统计';
$lang->testtask->report->charts['testTaskPerRunner'] = '用例执行人统计';
$lang->testtask->report->charts['bugSeverityGroups'] = 'Bug严重级别分布';
$lang->testtask->report->charts['bugStatusGroups'] = 'Bug状态分布';
$lang->testtask->report->charts['bugOpenedByGroups'] = 'Bug创建者分布';
$lang->testtask->report->charts['bugResolvedByGroups'] = 'Bug解决者分布';
$lang->testtask->report->charts['bugResolutionGroups'] = 'Bug解决方案分布';
$lang->testtask->report->charts['bugModuleGroups'] = 'Bug模块分布';
$lang->testtask->report->options = new stdclass();
$lang->testtask->report->options->graph = new stdclass();
$lang->testtask->report->options->type = 'pie';
$lang->testtask->report->options->width = 500;
$lang->testtask->report->options->height = 140;
$lang->testtask->report->testTaskPerRunResult = new stdclass();
$lang->testtask->report->testTaskPerType = new stdclass();
$lang->testtask->report->testTaskPerModule = new stdclass();
$lang->testtask->report->testTaskPerRunner = new stdclass();
$lang->testtask->report->testTaskPerRunResult->graph = new stdclass();
$lang->testtask->report->testTaskPerType->graph = new stdclass();
$lang->testtask->report->testTaskPerModule->graph = new stdclass();
$lang->testtask->report->testTaskPerRunner->graph = new stdclass();
+3 -1
View File
@@ -447,9 +447,10 @@ class testtaskModel extends model
*/
public function mergeChartOption($chartType)
{
$chartOption = $this->lang->testtask->report->$chartType;
$chartOption = isset($this->lang->testtask->report->$chartType) ? $this->lang->testtask->report->$chartType : new stdclass();
$commonOption = $this->lang->testtask->report->options;
if(!isset($chartOption->graph)) $chartOption->graph = new stdclass();
$chartOption->graph->caption = $this->lang->testtask->report->charts[$chartType];
if(!isset($chartOption->type)) $chartOption->type = $commonOption->type;
if(!isset($chartOption->width)) $chartOption->width = $commonOption->width;
@@ -457,6 +458,7 @@ class testtaskModel extends model
/* 合并配置。*/
foreach($commonOption->graph as $key => $value) if(!isset($chartOption->graph->$key)) $chartOption->graph->$key = $value;
return $chartOption;
}
/**
+1 -1
View File
@@ -43,7 +43,7 @@
if($this->methodName == 'cases') echo "<li id='bysearchTab'><a href='#'><i class='icon-search icon'></i>&nbsp;{$lang->testcase->bySearch}</a></li> ";
if(common::hasPriv('testtask', 'view')) echo '<li>' . html::a(inlink('view', "taskID=$taskID"), $lang->testtask->view) . '</li>';
if(common::hasPriv('testreport', 'browse')) echo '<li>' . html::a($this->createLink('testreport', 'browse', "objectID=$productID&objectType=product&extra=$taskID"), $lang->testtask->report) . '</li>';
if(common::hasPriv('testreport', 'browse')) echo '<li>' . html::a($this->createLink('testreport', 'browse', "objectID=$productID&objectType=product&extra=$taskID"), $lang->testtask->reportField) . '</li>';
?>
</div>
<div class='actions'>
+1 -1
View File
@@ -54,7 +54,7 @@
</div>
</td>
<td style='width: 320px'>
<?php $height = zget($lang->testtask->report->$chartType, 'height', $lang->testtask->report->options->height) . 'px'; ?>
<?php $height = $chartOption->height . 'px'; ?>
<div style="overflow:auto" class='table-wrapper'>
<table class='table table-condensed table-hover table-striped table-bordered table-chart' data-chart='<?php echo $chartOption->type; ?>' data-target='#chart-<?php echo $chartType ?>' data-animation='false'>
<thead>