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];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -105,17 +105,15 @@ class IDF_Views_Issue
|
||||
|
||||
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 coalesce(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);
|
||||
foreach ($dbData as $k => $v) {
|
||||
$key = ($v['name'] === null) ? __('Not assigned') : $v['name'];
|
||||
$ownerStatistics[$key] = array($v['nb'], (int)(100 * $v['nb'] / $opened));
|
||||
$owners = $prj->getIssueCountByOwner('open');
|
||||
foreach ($owners as $user => $nb) {
|
||||
if ($user === '') {
|
||||
$key = __('Not assigned');
|
||||
} else {
|
||||
$obj = Pluf::factory('Pluf_User')->getOne(array('filter'=>'id='.$user));
|
||||
$key = $obj->first_name . ' ' . $obj->last_name;
|
||||
}
|
||||
$ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened));
|
||||
}
|
||||
|
||||
// Issue class tag statistics
|
||||
|
Loading…
Reference in New Issue
Block a user