Fix the special case of a empty issue tracker, for the issue summary.

This commit is contained in:
William MARTIN 2011-06-15 11:18:41 +02:00
parent 69ae1c08ef
commit ef5b93e3f7
3 changed files with 123 additions and 104 deletions

View File

@ -84,25 +84,35 @@ class IDF_Views_Issue
public $summary_precond = array('IDF_Precondition::accessIssues');
public function summary($request, $match)
{
$tagStatistics = array();
$ownerStatistics = array();
$status = array();
$isTrackerEmpty = false;
$prj = $request->project;
$opened = $prj->getIssueCountByStatus('open');
$closed = $prj->getIssueCountByStatus('closed');
$otags = implode(',', $prj->getTagIdsByStatus('open'));
// Check if the tracker is empty
if ($opened === 0 && $closed === 0) {
$isTrackerEmpty = true;
} else {
if ($opened > 0 || $closed > 0) {
// Issue status statistics
$status = array();
$status['Open'] = array($opened, (int)(100 * $opened / ($opened + $closed)));
$status['Closed'] = array($closed, (int)(100 * $closed / ($opened + $closed)));
}
if ($opened > 0) {
// Issue owner statistics
$sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable();
$sqlUsersTable = Pluf::factory('Pluf_User')->getSqlTable();
$otags = implode(',', $prj->getTagIdsByStatus('open'));
$query = <<<"QUERY"
SELECT CONCAT(first_name, " ", last_name) as name, nb FROM (SELECT uid as id,count(uid) as nb FROM (SELECT ifnull(owner, -1) as uid FROM $sqlIssueTable WHERE status IN ($otags)) as ff group by uid) AS ff LEFT JOIN $sqlUsersTable using(id)
QUERY;
$db = Pluf::db();
$dbData = $db->select($query);
$ownerStatistics = array();
foreach ($dbData as $k => $v) {
$key = ($v['name'] === null) ? __('Not assigned') : $v['name'];
$ownerStatistics[$key] = array($v['nb'], (int)(100 * $v['nb'] / $opened));
@ -110,7 +120,6 @@ QUERY;
// Issue class tag statistics
$tags = $prj->getTagCloud();
$tagStatistics = array();
foreach ($tags as $t) {
$tagStatistics[$t->class][$t->name] = array($t->nb_use, $t->id);
}
@ -127,10 +136,14 @@ QUERY;
// Sort
krsort($tagStatistics);
arsort($ownerStatistics);
}
}
$title = sprintf(__('Summary of tracked issues in %s.'), (string) $prj);
return Pluf_Shortcuts_RenderToResponse('idf/issues/summary.html',
array('page_title' => $title,
'trackerEmpty' => $isTrackerEmpty,
'project' => $prj,
'tagStatistics' => $tagStatistics,
'ownerStatistics' => $ownerStatistics,

View File

@ -3,6 +3,10 @@
{block docclass}yui-t2{assign $inSummaryIssues=true}{/block}
{block body}
{if $trackerEmpty}
{aurl 'create_url', 'IDF_Views_Issue::create', array($project.shortname)}
<p>{blocktrans}The issue tracker is empty<br />You can create your first issue <a href="{$create_url}">here</a>.{/blocktrans}</p>
{else}
<div class='issue-summary'>
{foreach $tagStatistics as $key => $class}
<div>
@ -33,7 +37,7 @@
</div>
<div class='issue-summary'>
{if $status}
<div>
<h2>Status Summary</h2>
<table class='issue-summary'>
@ -58,7 +62,9 @@
</tbody>
</table>
</div>
{/if}
{if $ownerStatistics}
<div>
<h2>Unresolved: By Assignee</h2>
<table class='issue-summary'>
@ -83,7 +89,7 @@
</tbody>
</table>
</div>
{/if}
</div>
{/if}
{/block}

View File

@ -1128,7 +1128,7 @@ table.issue-summary {
table.issue-summary tr td {
border: 0;
padding: .1em;
padding: .1em .005em;
}
table.issue-summary td.graph {