Add IDF_Project::getIssueCountByOwner and use it into IDF_Views_Issue::summary
This commit is contained in:
parent
6e7c9f7c4b
commit
6d55602ef3
@ -132,6 +132,47 @@ class IDF_Project extends Pluf_Model
|
|||||||
}
|
}
|
||||||
return $projects[0];
|
return $projects[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of open/closed issues.
|
||||||
|
*
|
||||||
|
* @param string Status ('open'), 'closed'
|
||||||
|
* @param IDF_Tag Subfilter with a label (null)
|
||||||
|
* @return int Count
|
||||||
|
*/
|
||||||
|
public function getIssueCountByOwner($status='open')
|
||||||
|
{
|
||||||
|
switch ($status) {
|
||||||
|
case 'open':
|
||||||
|
$tags = implode(',', $this->getTagIdsByStatus('open'));
|
||||||
|
break;
|
||||||
|
case 'closed':
|
||||||
|
default:
|
||||||
|
$tags = implode(',', $this->getTagIdsByStatus('closed'));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable();
|
||||||
|
$query = <<<"QUERY"
|
||||||
|
SELECT uid AS id,COUNT(uid) AS nb
|
||||||
|
FROM (
|
||||||
|
SELECT COALESCE(owner, -1) AS uid
|
||||||
|
FROM $sqlIssueTable
|
||||||
|
WHERE status IN ($tags)
|
||||||
|
) AS ff
|
||||||
|
GROUP BY uid
|
||||||
|
QUERY;
|
||||||
|
$db = Pluf::db();
|
||||||
|
$dbData = $db->select($query);
|
||||||
|
$ownerStatistics = array();
|
||||||
|
foreach ($dbData as $k => $v) {
|
||||||
|
$key = ($v['id'] === '-1') ? null : $v['id'];
|
||||||
|
$ownerStatistics[$key] = (int)$v['nb'];
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($ownerStatistics);
|
||||||
|
|
||||||
|
return $ownerStatistics;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of open/closed issues.
|
* Returns the number of open/closed issues.
|
||||||
|
@ -105,17 +105,15 @@ class IDF_Views_Issue
|
|||||||
|
|
||||||
if ($opened > 0) {
|
if ($opened > 0) {
|
||||||
// Issue owner statistics
|
// Issue owner statistics
|
||||||
$sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable();
|
$owners = $prj->getIssueCountByOwner('open');
|
||||||
$sqlUsersTable = Pluf::factory('Pluf_User')->getSqlTable();
|
foreach ($owners as $user => $nb) {
|
||||||
$otags = implode(',', $prj->getTagIdsByStatus('open'));
|
if ($user === '') {
|
||||||
$query = <<<"QUERY"
|
$key = __('Not assigned');
|
||||||
SELECT CONCAT(first_name, " ", last_name) as name, nb FROM (SELECT uid as id,count(uid) as nb FROM (SELECT coalesce(owner, -1) as uid FROM $sqlIssueTable WHERE status IN ($otags)) as ff group by uid) AS ff LEFT JOIN $sqlUsersTable using(id)
|
} else {
|
||||||
QUERY;
|
$obj = Pluf::factory('Pluf_User')->getOne(array('filter'=>'id='.$user));
|
||||||
$db = Pluf::db();
|
$key = $obj->first_name . ' ' . $obj->last_name;
|
||||||
$dbData = $db->select($query);
|
}
|
||||||
foreach ($dbData as $k => $v) {
|
$ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened));
|
||||||
$key = ($v['name'] === null) ? __('Not assigned') : $v['name'];
|
|
||||||
$ownerStatistics[$key] = array($v['nb'], (int)(100 * $v['nb'] / $opened));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue class tag statistics
|
// Issue class tag statistics
|
||||||
|
Loading…
Reference in New Issue
Block a user