Indefero

Indefero Commit Details


Date:2012-03-30 09:20:05 (12 years 8 months ago)
Author:Simon Holywell
Branch:develop
Commit:3bf497746058df8534648acc84999437a37931ff
Parents: 315e06da1bb38f836e2941a9fe16a8dac943e324
Message:Closes issue 3: Issues list left hand navigation - controls for issue due date

Changes:

File differences

src/IDF/Project.php
201201
202202
203203
204
204
205205
206
206
207207
208
209208
210209
211
210
212211
213
214
215
216
217
218
219
220
221
222
223
224
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
225247
226248
227249
return $ownerStatistics;
}
/**
* Returns the number of overdue/in date issues.
* Returns the number of overdue issues.
*
* @param string Status ('open'), 'closed'
* @return int Count
*/
public function getIssueCountByOverdue()
public function getIssueCountByDueDate($due='overdue', $status='open', $label=null, $ids=array())
{
$tags = implode(',', $this->getTagIdsByStatus('open'));
$sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable();
$query = "SELECT (
SELECT COUNT(*) FROM $sqlIssueTable
WHERE due_dtime < NOW() AND status IN ($tags)
) AS overdue,
( SELECT COUNT(*) FROM $sqlIssueTable
WHERE due_dtime >= NOW() AND status IN ($tags)
) AS undue";
$db = Pluf::db();
$dbData = $db->select($query);
return current($dbData);
switch ($status) {
case 'open':
$key = 'labels_issue_open';
$default = IDF_Form_IssueTrackingConf::init_open;
break;
case 'closed':
default:
$key = 'labels_issue_closed';
$default = IDF_Form_IssueTrackingConf::init_closed;
break;
}
$tags = array();
foreach ($this->getTagsFromConfig($key, $default, 'Status') as $tag) {
$tags[] = (int)$tag->id;
}
if (count($tags) == 0) return array();
$sql = new Pluf_SQL(sprintf('project=%%s AND status IN (%s)', implode(', ', $tags)), array($this->id));
if (!is_null($label)) {
$sql2 = new Pluf_SQL('idf_tag_id=%s', array($label->id));
$sql->SAnd($sql2);
}
if (count($ids) > 0) {
$sql2 = new Pluf_SQL(sprintf('id IN (%s)', implode(', ', $ids)));
$sql->SAnd($sql2);
}
if('overdue' === $due) {
$sql3 = new Pluf_SQL('due_dtime < NOW()');
} else {
$sql3 = new Pluf_SQL('due_dtime >= NOW()');
}
$sql->SAnd($sql3);
$params = array('filter' => $sql->gen());
if (!is_null($label)) { $params['view'] = 'join_tags'; }
$gissue = new IDF_Issue();
return $gissue->getCount($params);
}
/**
src/IDF/Views/Issue.php
4242
4343
4444
45
4546
4647
4748
......
7273
7374
7475
76
7577
7678
7779
......
123125
124126
125127
126
127
128
129
130
128131
129132
130
131
133
134
132135
133136
134137
......
140143
141144
142145
143
146
144147
145148
146149
......
198201
199202
200203
204
205
201206
202207
203208
209
210
211
212
213
204214
205215
206216
......
243253
244254
245255
256
246257
247258
248259
......
282293
283294
284295
296
297
285298
286299
287300
301
302
303
304
305
288306
289307
290308
......
325343
326344
327345
346
328347
329348
330349
......
339358
340359
341360
342
361
343362
344363
345364
......
347366
348367
349368
350
369
351370
352371
353372
......
374393
375394
376395
377
396
378397
379398
380399
......
476495
477496
478497
479
498
480499
481500
482501
......
485504
486505
487506
488
507
489508
490509
491510
......
505524
506525
507526
527
528
529
530
508531
509532
510533
......
525548
526549
527550
551
552
553
554
528555
529556
530557
......
578605
579606
580607
608
581609
582610
583611
......
599627
600628
601629
630
602631
603632
604633
......
752781
753782
754783
755
784
756785
757786
758787
759
788
760789
761
790
762791
763792
764793
765794
795
766796
767797
768798
......
794824
795825
796826
827
797828
798829
799830
......
808839
809840
810841
811
842
812843
813844
814845
815846
847
816848
817849
818850
......
849881
850882
851883
884
852885
853886
854887
......
864897
865898
866899
867
900
868901
869902
870903
871904
872905
906
907
908
909
910
873911
874912
875913
......
877915
878916
879917
918
880919
881920
882921
......
888927
889928
890929
930
931
932
891933
892934
893935
......
916958
917959
918960
961
919962
920963
921964
// Get stats about the issues
$open = $prj->getIssueCountByStatus('open');
$closed = $prj->getIssueCountByStatus('closed');
$overdue = $prj->getIssueCountByDueDate('overdue');
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
'page_title' => $title,
'open' => $open,
'closed' => $closed,
'overdue' => $overdue,
'issues' => $pag,
'cloud' => 'issues',
);
arsort($ownerStatistics);
// Issue due date statistics
$overdue = $prj->getIssueCountByOverdue('open');
$combined_opened = $overdue['overdue'] + $overdue['undue'];
$overdue = $prj->getIssueCountByDueDate('overdue');
$undue = $prj->getIssueCountByDueDate('undue');
$combined_opened = $overdue + $undue;
$duedateStatistics = array();
if($combined_opened > 0) {
$duedateStatistics['Overdue'] = array($overdue['overdue'], (int)(100 * $overdue['overdue'] / $combined_opened), 'Overdue');
$duedateStatistics['Undue'] = array($overdue['undue'], (int)(100 * $overdue['undue'] / $combined_opened), 'Undue');
$duedateStatistics['Overdue'] = array($overdue, (int)(100 * $overdue / $combined_opened), 'Overdue');
$duedateStatistics['Undue'] = array($undue, (int)(100 * $undue / $combined_opened), 'Undue');
}
// Issue class tag statistics
uasort($tagStatistics[$class], function ($a, $b) {
if ($a[0] === $b[0])
return 0;
return ($a[0] > $b[0]) ? -1 : 1;
});
}
$nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
$nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).') AND due_dtime < NOW()', array($prj->id));
$nb_overdue = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Generate a filter for the paginator
switch ($match[2]) {
case 'overdue':
$title = sprintf(__('Watch List: Overdue Issues for %s'), (string) $prj);
$summary = __('This table shows the overdue issues in your watch list for %s project.', (string) $prj);
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).') AND due_dtime < NOW()', array($prj->id));
break;
case 'closed':
$title = sprintf(__('Watch List: Closed Issues for %s'), (string) $prj);
$summary = __('This table shows the closed issues in your watch list for %s project.', (string) $prj);
'page_title' => $title,
'open' => $nb_open,
'closed' => $nb_closed,
'overdue' => $nb_overdue,
'issues' => $pag,
),
$request);
$nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array());
$nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).') AND due_dtime < NOW()', array());
$nb_overdue = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Generate a filter for the paginator
switch ($match[1]) {
case 'overdue':
$title = sprintf(__('Watch List: Overdue Issues'));
$summary = __('This table shows the overdue issues in your watch list.');
$f_sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).') AND due_dtime < NOW()', array());
break;
case 'closed':
$title = sprintf(__('Watch List: Closed Issues'));
$summary = __('This table shows the closed issues in your watch list.');
array('page_title' => $title,
'open' => $nb_open,
'closed' => $nb_closed,
'overdue' => $nb_overdue,
'issues' => $pag,
),
$request);
public function userIssues($request, $match)
{
$prj = $request->project;
$sql = new Pluf_SQL('login=%s', array($match[2]));
$user = Pluf::factory('Pluf_User')->getOne(array('filter' => $sql->gen()));
if ($user === null) {
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
$otags = $prj->getTagIdsByStatus('open');
$ctags = $prj->getTagIdsByStatus('closed');
if (count($otags) == 0) $otags[] = 0;
$user->first_name,
$user->last_name,
(string) $prj);
// Get stats about the issues
$sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id));
$nb_submit = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
public function searchStatus($request, $match)
{
$query = !isset($request->REQUEST['q']) ? '' : $request->REQUEST['q'];
$status = in_array($match[2], array('open', 'closed')) ? $match[2] : 'open';
$status = in_array($match[2], array('open', 'closed', 'overdue')) ? $match[2] : 'open';
return $this->doSearch($request, $query, $status);
}
{
$query = !isset($request->REQUEST['q']) ? '' : $request->REQUEST['q'];
$tag_id = intval($match[2]);
$status = in_array($match[3], array('open', 'closed')) ? $match[3] : 'open';
$status = in_array($match[3], array('open', 'closed', 'overdue')) ? $match[3] : 'open';
return $this->doSearch($request, $query, $status, $tag_id);
}
$title = sprintf(__('Search issues - %s'), $query);
if ($status === 'closed') {
$title = sprintf(__('Search closed issues - %s'), $query);
} elseif ($status === 'overdue') {
$title = sprintf(__('Search overdue issues - %s'), $query);
$status = 'open';
$overdue_status = true;
}
// using Plufs ResultSet implementation here is inefficient, because
'AND status IN ('.implode(', ', $otags).') '.
($tag_id !== null ? 'AND idf_tag_id='.$tag_id.' ' : '')
);
if(isset($overdue_status)) {
$sql2 = new Pluf_SQL('due_dtime < NOW()');
$sql->SAnd($sql2);
}
$model = new IDF_Issue();
$issues = $model->getList(array('filter' => $sql->gen(), 'view' => 'join_tags'));
}
// get stats about the issues
$overdue = $prj->getIssueCountByDueDate('overdue', 'open', $tag, $issue_ids);
$open = $prj->getIssueCountByStatus('open', $tag, $issue_ids);
$closed = $prj->getIssueCountByStatus('closed', $tag, $issue_ids);
'status' => $status,
'open' => $open,
'closed' => $closed,
'overdue' => $overdue,
'tag' => $tag,
'all_tags' => $grouped_tags,
);
{
$prj = $request->project;
$status = $match[2];
if (mb_strtolower($status) == 'open') {
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
return new Pluf_HTTP_Response_Redirect($url);
}
$title = sprintf(__('%s Closed Issues'), (string) $prj);
// Get stats about the issues
$open = $prj->getIssueCountByStatus('open');
$closed = $prj->getIssueCountByStatus('closed');
$overdue = $prj->getIssueCountByDueDate('overdue');
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
'page_title' => $title,
'open' => $open,
'closed' => $closed,
'overdue' => $overdue,
'issues' => $pag,
'cloud' => 'closed_issues',
),
{
$prj = $request->project;
$status = $match[2];
$title = sprintf(__('%s %s Issues'), (string) $prj, (string) $status);
// Get stats about the issues
$open = $prj->getIssueCountByStatus('open');
$closed = $prj->getIssueCountByStatus('closed');
$overdue = $prj->getIssueCountByDueDate('overdue');
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
'page_title' => $title,
'open' => $open,
'closed' => $closed,
'overdue' => $overdue,
'issues' => $pag,
'cloud' => 'closed_issues',
),
$prj = $request->project;
$tag = Pluf_Shortcuts_GetObjectOr404('IDF_Tag', $match[2]);
$status = $match[3];
if ($tag->project != $prj->id or !in_array($status, array('open', 'closed'))) {
if ($tag->project != $prj->id or !in_array($status, array('open', 'closed', 'overdue'))) {
throw new Pluf_HTTP_Error404();
}
if ($status == 'open') {
$title = sprintf(__('%1$s Issues with Label %2$s'), (string) $prj,
(string) $tag);
} elseif ($status == 'overdue') {
$title = sprintf(__('%1$s Overdue Issues with Label %2$s'), (string) $prj,
(string) $tag);
$overdue_status = true;
$status = 'open';
} else {
$title = sprintf(__('%1$s Closed Issues with Label %2$s'),
(string) $prj, (string) $tag);
// Get stats about the open/closed issues having this tag.
$open = $prj->getIssueCountByStatus('open', $tag);
$closed = $prj->getIssueCountByStatus('closed', $tag);
$overdue = $prj->getIssueCountByDueDate('overdue', 'open', $tag);
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->model_view = 'join_tags';
$otags = $prj->getTagIdsByStatus($status);
if (count($otags) == 0) $otags[] = 0;
$pag->forced_where = new Pluf_SQL('project=%s AND idf_tag_id=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $tag->id));
if(isset($overdue_status)) {
$pag->forced_where->SAnd(new Pluf_SQL('due_dtime < NOW()'));
}
$pag->action = array('IDF_Views_Issue::listLabel', array($prj->shortname, $tag->id, $status));
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
'open' => $open,
'label' => $tag,
'closed' => $closed,
'overdue' => $overdue,
'issues' => $pag,
),
$request);
src/IDF/templates/idf/issues/by-label.html
1212
1313
1414
15
16
17
18
1519
1620
1721
{aurl 'closed_url', 'IDF_Views_Issue::listLabel', array($project.shortname, $label.id, 'closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>
<p>
{aurl 'overdue_url', 'IDF_Views_Issue::listLabel', array($project.shortname, $label.id, 'overdue')}
<span>Overdue:</span> <a href="{$overdue_url}">{$overdue}</a>
</p>
{/blocktrans}
<p><strong>{trans 'Label:'}</strong>
{aurl 'url', 'IDF_Views_Issue::listLabel', array($project.shortname, $label.id, 'open')}
src/IDF/templates/idf/issues/forge-watchlist.html
88
99
1010
11
11
12
13
14
15
16
1217
{aurl 'open_url', 'IDF_Views_Issue::forgeWatchList', array('open')}
{aurl 'closed_url', 'IDF_Views_Issue::forgeWatchList', array('closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>
<p>
{aurl 'overdue_url', 'IDF_Views_Issue::forgeWatchList', array('overdue')}
<span>Overdue:</span> <a href="{$overdue_url}">{$overdue}</a>
</p>
{/blocktrans}
{/block}
src/IDF/templates/idf/issues/index.html
1111
1212
1313
14
14
15
16
17
18
1519
1620
1721
{aurl 'open_url', 'IDF_Views_Issue::index', array($project.shortname)}
{aurl 'closed_url', 'IDF_Views_Issue::listStatus', array($project.shortname, 'closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>
<p>
{aurl 'overdue_url', 'IDF_Views_Issue::listOverdue', array($project.shortname, 'Overdue', 'overdue')}
<span>Overdue:</span> <a href="{$overdue_url}">{$overdue}</a>
</p>{/blocktrans}
{assign $cloud_url = 'IDF_Views_Issue::listLabel'}
{include 'idf/tags-cloud.html'}
{/block}
src/IDF/templates/idf/issues/project-watchlist.html
1313
1414
1515
16
16
17
18
19
20
1721
{aurl 'open_url', 'IDF_Views_Issue::watchList', array($project.shortname, 'open')}
{aurl 'closed_url', 'IDF_Views_Issue::watchList', array($project.shortname, 'closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>
<p>
{aurl 'overdue_url', 'IDF_Views_Issue::watchList', array($project.shortname, 'overdue')}
<span>Overdue:</span> <a href="{$overdue_url}">{$overdue}</a>
</p>{/blocktrans}
{/block}
src/IDF/templates/idf/issues/search.html
1010
1111
1212
13
1314
1415
1516
17
1618
1719
1820
19
21
22
2023
2124
2225
{block context}
{aurl 'open_url', 'IDF_Views_Issue::searchStatus', array($project.shortname, 'open'), array('q' => $query)}
{aurl 'closed_url', 'IDF_Views_Issue::searchStatus', array($project.shortname, 'closed'), array('q' => $query)}
{aurl 'overdue_url', 'IDF_Views_Issue::searchStatus', array($project.shortname, 'overdue'), array('q' => $query)}
{if $tag != null}
{aurl 'open_url', 'IDF_Views_Issue::searchLabel', array($project.shortname, $tag.id, 'open'), array('q' => $query)}
{aurl 'closed_url', 'IDF_Views_Issue::searchLabel', array($project.shortname, $tag.id, 'closed'), array('q' => $query)}
{aurl 'overdue_url', 'IDF_Views_Issue::searchLabel', array($project.shortname, $tag.id, 'overdue'), array('q' => $query)}
{/if}
{blocktrans}
<p><strong>Found open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Found closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
<p><strong>Found closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>
<p>Found overdue issues: <a href="{$overdue_url}">{$overdue}</a></p>{/blocktrans}
{if $tag !== null}
{blocktrans}<p><strong>Label:</strong>
<a href="{$open_url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></p>{/blocktrans}

Archive Download the corresponding diff file

Page rendered in 0.10165s using 14 queries.