* code for task#1363.

This commit is contained in:
chencongzhi520@gmail.com
2013-05-03 05:51:27 +00:00
parent d6754d029e
commit 4f88d135aa
4 changed files with 21 additions and 15 deletions

View File

@@ -68,7 +68,8 @@ $lang->report->to = 'to';
$lang->report->taskTotal = "Task Total";
$lang->report->manhourTotal = "Manhour Total";
$lang->report->bugTotal = "%s Bugs";
$lang->report->effectiveRate = "Effective Rate";
$lang->report->validRate = "Valid Rate";
$lang->report->validRateTips = "Resolution is fixed or postponed/status is resolved";
$lang->report->unplanned = 'unplanned';
/* daily reminder. */

View File

@@ -68,7 +68,8 @@ $lang->report->to = '至';
$lang->report->taskTotal = "总任务数";
$lang->report->manhourTotal = "总工时";
$lang->report->bugTotal = "共%s个Bug";
$lang->report->effectiveRate = "有效率";
$lang->report->validRate = "有效率";
$lang->report->validRateTips = "方案为已解决或延期/状态为已解决";
$lang->report->unplanned = '未计划';
/* daily reminder. */

View File

@@ -391,27 +391,31 @@ EOT;
public function getBugs($begin, $end)
{
$end = date('Ymd', strtotime("$end +1 day"));
$bugs = $this->dao->select('id, resolution, openedBy')->from(TABLE_BUG)
$bugs = $this->dao->select('id, resolution, openedBy, status')->from(TABLE_BUG)
->where('deleted')->eq(0)
->andWhere('openedDate')->ge($begin)
->andWhere('openedDate')->le($end)
->fetchAll();
$bugSummary = array();
foreach($bugs as $bug)
{
$bugSummary[$bug->openedBy][$bug->resolution] = empty($bugSummary[$bug->openedBy][$bug->resolution]) ? 1 : $bugSummary[$bug->openedBy][$bug->resolution] + 1;
$bugSummary[$bug->openedBy]['all'] = empty($bugSummary[$bug->openedBy]['all']) ? 1 : $bugSummary[$bug->openedBy]['all'] + 1;
$bugSummary[$bug->openedBy]['all'] = empty($bugSummary[$bug->openedBy]['all']) ? 1 : $bugSummary[$bug->openedBy]['all'] + 1;
if($bug->status == 'resolved')
{
$bugSummary[$bug->openedBy]['resolved'] = empty($bugSummary[$bug->openedBy]['resolved']) ? 1 : $bugSummary[$bug->openedBy]['resolved'] + 1;
}
}
foreach($bugSummary as $account => $bug)
{
$effectiveRate = 0;
if(isset($bug['fixed'])) $effectiveRate += $bug['fixed'];
if(isset($bug['external'])) $effectiveRate += $bug['external'];
if(isset($bug['postponed'])) $effectiveRate += $bug['postponed'];
$bugSummary[$account]['effectiveRate'] = $bug['all'] ? ($effectiveRate / $bug['all']) : "0";
$validRate = 0;
if(isset($bug['fixed'])) $validRate += $bug['fixed'];
if(isset($bug['postponed'])) $validRate += $bug['postponed'];
$bugSummary[$account]['validRate'] = (isset($bug['resolved']) and $bug['resolved']) ? ($validRate / $bug['resolved']) : "0";
}
uasort($bugSummary, 'summaryCmp');
uasort($bugSummary, 'sortSummary');
return $bugSummary;
}
@@ -573,8 +577,8 @@ EOT;
}
}
function summaryCmp($pre, $next)
function sortSummary($pre, $next)
{
if($pre['effectiveRate'] == $next['effectiveRate']) return 0;
return $pre['effectiveRate'] > $next['effectiveRate'] ? -1 : 1;
if($pre['validRate'] == $next['validRate']) return 0;
return $pre['validRate'] > $next['validRate'] ? -1 : 1;
}

View File

@@ -25,7 +25,7 @@
<th><?php echo $lang->bug->resolutionList['postponed'];?></th>
<th><?php echo $lang->bug->resolutionList['willnotfix'];?></th>
<th><?php echo $lang->bug->resolutionList['tostory'];?></th>
<th><?php echo $lang->report->effectiveRate;?></th>
<th title='<?php echo $lang->report->validRateTips;?>'><?php echo $lang->report->validRate;?></th>
</tr>
</thead>
<tbody>
@@ -43,7 +43,7 @@
<td><?php echo isset($bug['postponed']) ? $bug['postponed'] : 0;?></td>
<td><?php echo isset($bug['willnotfix']) ? $bug['willnotfix'] : 0;?></td>
<td><?php echo isset($bug['tostory']) ? $bug['tostory'] : 0;?></td>
<td><?php echo round($bug['effectiveRate'] * 100, 2) . '%';?></td>
<td><?php echo round($bug['validRate'] * 100, 2) . '%';?></td>
</tr>
<?php endforeach;?>
</tbody>