Indefero

Indefero Commit Details


Date:2011-06-15 10:30:23 (13 years 6 months ago)
Author:William MARTIN
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:6d55602ef38c50d748afa83ee305cc1f78a8c743
Parents: 6e7c9f7c4b6a6e03461e04b80edcf4867a71e6fc
Message:Add IDF_Project::getIssueCountByOwner and use it into IDF_Views_Issue::summary

Changes:

File differences

src/IDF/Project.php
132132
133133
134134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
135176
136177
137178
}
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.
src/IDF/Views/Issue.php
105105
106106
107107
108
109
110
111
112
113
114
115
116
117
118
108
109
110
111
112
113
114
115
116
119117
120118
121119
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

Archive Download the corresponding diff file

Page rendered in 0.08012s using 13 queries.