2011-02-08 10:53:59 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2011 Facebook, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class ManiphestTaskListController extends ManiphestController {
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
const DEFAULT_PAGE_SIZE = 1000;
|
|
|
|
|
|
2011-02-08 10:53:59 -08:00
|
|
|
private $view;
|
|
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
|
$this->view = idx($data, 'view');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
2011-04-11 02:03:30 -07:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
$uri = $request->getRequestURI();
|
|
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
|
$phid_arr = $request->getArr('view_user');
|
|
|
|
|
$view_target = head($phid_arr);
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
|
->setURI($request->getRequestURI()->alter('phid', $view_target));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-08 10:53:59 -08:00
|
|
|
$views = array(
|
2011-04-11 02:03:30 -07:00
|
|
|
'User Tasks',
|
2011-02-11 10:28:37 -08:00
|
|
|
'action' => 'Assigned',
|
2011-02-08 10:53:59 -08:00
|
|
|
'created' => 'Created',
|
|
|
|
|
'triage' => 'Need Triage',
|
2011-02-11 10:28:37 -08:00
|
|
|
// 'touched' => 'Touched',
|
2011-02-09 16:29:46 -08:00
|
|
|
'<hr />',
|
2011-02-11 10:28:37 -08:00
|
|
|
'All Tasks',
|
2011-02-09 16:29:46 -08:00
|
|
|
'alltriage' => 'Need Triage',
|
|
|
|
|
'unassigned' => 'Unassigned',
|
2011-02-11 10:28:37 -08:00
|
|
|
'all' => 'All Tasks',
|
2011-02-08 10:53:59 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (empty($views[$this->view])) {
|
2011-02-09 16:29:46 -08:00
|
|
|
$this->view = 'action';
|
2011-02-08 10:53:59 -08:00
|
|
|
}
|
|
|
|
|
|
2011-04-11 02:03:30 -07:00
|
|
|
$has_filter = array(
|
|
|
|
|
'action' => true,
|
|
|
|
|
'created' => true,
|
|
|
|
|
'triage' => true,
|
|
|
|
|
);
|
2011-02-08 10:53:59 -08:00
|
|
|
|
|
|
|
|
$nav = new AphrontSideNavView();
|
|
|
|
|
foreach ($views as $view => $name) {
|
2011-02-09 16:29:46 -08:00
|
|
|
if (is_integer($view)) {
|
|
|
|
|
$nav->addNavItem(
|
|
|
|
|
phutil_render_tag(
|
|
|
|
|
'span',
|
|
|
|
|
array(),
|
|
|
|
|
$name));
|
|
|
|
|
} else {
|
2011-02-11 10:28:37 -08:00
|
|
|
$uri->setPath('/maniphest/view/'.$view.'/');
|
2011-02-09 16:29:46 -08:00
|
|
|
$nav->addNavItem(
|
|
|
|
|
phutil_render_tag(
|
|
|
|
|
'a',
|
|
|
|
|
array(
|
2011-02-11 10:28:37 -08:00
|
|
|
'href' => $uri,
|
2011-02-09 16:29:46 -08:00
|
|
|
'class' => ($this->view == $view)
|
|
|
|
|
? 'aphront-side-nav-selected'
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
phutil_escape_html($name)));
|
|
|
|
|
}
|
2011-02-08 10:53:59 -08:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
list($status_map, $status_links) = $this->renderStatusLinks();
|
|
|
|
|
list($grouping, $group_links) = $this->renderGroupLinks();
|
|
|
|
|
list($order, $order_links) = $this->renderOrderLinks();
|
|
|
|
|
|
2011-04-11 02:03:30 -07:00
|
|
|
$view_phid = nonempty($request->getStr('phid'), $user->getPHID());
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$page = $request->getInt('page');
|
|
|
|
|
$page_size = self::DEFAULT_PAGE_SIZE;
|
|
|
|
|
|
|
|
|
|
list($tasks, $handles, $total_count) = $this->loadTasks(
|
2011-04-11 02:03:30 -07:00
|
|
|
$view_phid,
|
2011-02-11 10:28:37 -08:00
|
|
|
array(
|
|
|
|
|
'status' => $status_map,
|
|
|
|
|
'group' => $grouping,
|
|
|
|
|
'order' => $order,
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
'offset' => $page,
|
|
|
|
|
'limit' => $page_size,
|
2011-02-11 10:28:37 -08:00
|
|
|
));
|
2011-02-08 10:53:59 -08:00
|
|
|
|
|
|
|
|
|
2011-04-03 15:50:06 -07:00
|
|
|
$form = id(new AphrontFormView())
|
2011-04-11 02:03:30 -07:00
|
|
|
->setUser($user);
|
|
|
|
|
|
|
|
|
|
if (isset($has_filter[$this->view])) {
|
|
|
|
|
$form->appendChild(
|
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
|
->setLimit(1)
|
|
|
|
|
->setDatasource('/typeahead/common/users/')
|
|
|
|
|
->setName('view_user')
|
|
|
|
|
->setLabel('View User')
|
|
|
|
|
->setValue(
|
|
|
|
|
array(
|
|
|
|
|
$view_phid => $handles[$view_phid]->getFullName(),
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form
|
2011-04-03 15:50:06 -07:00
|
|
|
->appendChild(
|
|
|
|
|
id(new AphrontFormToggleButtonsControl())
|
|
|
|
|
->setLabel('Status')
|
|
|
|
|
->setValue($status_links))
|
|
|
|
|
->appendChild(
|
|
|
|
|
id(new AphrontFormToggleButtonsControl())
|
|
|
|
|
->setLabel('Group')
|
|
|
|
|
->setValue($group_links))
|
|
|
|
|
->appendChild(
|
|
|
|
|
id(new AphrontFormToggleButtonsControl())
|
|
|
|
|
->setLabel('Order')
|
|
|
|
|
->setValue($order_links));
|
|
|
|
|
|
|
|
|
|
$filter = new AphrontListFilterView();
|
|
|
|
|
$filter->addButton(
|
|
|
|
|
phutil_render_tag(
|
|
|
|
|
'a',
|
|
|
|
|
array(
|
|
|
|
|
'href' => '/maniphest/task/create/',
|
|
|
|
|
'class' => 'green button',
|
|
|
|
|
),
|
|
|
|
|
'Create New Task'));
|
|
|
|
|
$filter->appendChild($form);
|
|
|
|
|
|
|
|
|
|
$nav->appendChild($filter);
|
2011-02-11 10:28:37 -08:00
|
|
|
|
|
|
|
|
$have_tasks = false;
|
|
|
|
|
foreach ($tasks as $group => $list) {
|
|
|
|
|
if (count($list)) {
|
|
|
|
|
$have_tasks = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-03 15:50:06 -07:00
|
|
|
require_celerity_resource('maniphest-task-summary-css');
|
|
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
if (!$have_tasks) {
|
|
|
|
|
$nav->appendChild(
|
|
|
|
|
'<h1 class="maniphest-task-group-header">'.
|
|
|
|
|
'No matching tasks.'.
|
|
|
|
|
'</h1>');
|
|
|
|
|
} else {
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
|
$pager->setURI($request->getRequestURI(), 'page');
|
|
|
|
|
$pager->setPageSize($page_size);
|
|
|
|
|
$pager->setOffset($page);
|
|
|
|
|
$pager->setCount($total_count);
|
|
|
|
|
|
|
|
|
|
$cur = ($pager->getOffset() + 1);
|
|
|
|
|
$max = min($pager->getOffset() + $page_size, $total_count);
|
|
|
|
|
$tot = $total_count;
|
|
|
|
|
|
|
|
|
|
$cur = number_format($cur);
|
|
|
|
|
$max = number_format($max);
|
|
|
|
|
$tot = number_format($tot);
|
|
|
|
|
|
|
|
|
|
$nav->appendChild(
|
|
|
|
|
'<div class="maniphest-total-result-count">'.
|
|
|
|
|
"Displaying tasks {$cur} - {$max} of {$tot}.".
|
|
|
|
|
'</div>');
|
|
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
foreach ($tasks as $group => $list) {
|
|
|
|
|
$task_list = new ManiphestTaskListView();
|
Use phabricator_ time functions in more places
Summary:
Replace some more date() calls with locale-aware calls.
Also, at least on my system, the DateTimeZone / DateTime stuff didn't actually
work and always rendered in UTC. Fixed that.
Test Plan:
Viewed daemon console, differential revisions, files, and maniphest timestamps
in multiple timezones.
Reviewed By: toulouse
Reviewers: toulouse, fratrik, jungejason, aran, tuomaspelkonen
CC: aran, toulouse
Differential Revision: 530
2011-06-26 09:22:52 -07:00
|
|
|
$task_list->setUser($user);
|
2011-02-11 10:28:37 -08:00
|
|
|
$task_list->setTasks($list);
|
|
|
|
|
$task_list->setHandles($handles);
|
|
|
|
|
|
2011-06-13 20:03:44 -07:00
|
|
|
$count = number_format(count($list));
|
2011-02-11 10:28:37 -08:00
|
|
|
$nav->appendChild(
|
|
|
|
|
'<h1 class="maniphest-task-group-header">'.
|
2011-06-13 20:03:44 -07:00
|
|
|
phutil_escape_html($group).' ('.$count.')'.
|
2011-02-11 10:28:37 -08:00
|
|
|
'</h1>');
|
|
|
|
|
$nav->appendChild($task_list);
|
|
|
|
|
}
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
|
|
|
|
|
$nav->appendChild($pager);
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
2011-02-08 10:53:59 -08:00
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
|
$nav,
|
|
|
|
|
array(
|
|
|
|
|
'title' => 'Task List',
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-11 02:03:30 -07:00
|
|
|
private function loadTasks($view_phid, array $dict) {
|
|
|
|
|
$phids = array($view_phid);
|
2011-02-08 10:53:59 -08:00
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
$task = new ManiphestTask();
|
|
|
|
|
|
|
|
|
|
$argv = array();
|
|
|
|
|
|
|
|
|
|
$status = $dict['status'];
|
|
|
|
|
if (!empty($status['open']) && !empty($status['closed'])) {
|
|
|
|
|
$status_clause = '1 = 1';
|
|
|
|
|
} else if (!empty($status['open'])) {
|
|
|
|
|
$status_clause = 'status = %d';
|
|
|
|
|
$argv[] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$status_clause = 'status > %d';
|
|
|
|
|
$argv[] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$extra_clause = '1 = 1';
|
2011-02-08 10:53:59 -08:00
|
|
|
switch ($this->view) {
|
|
|
|
|
case 'action':
|
2011-02-11 10:28:37 -08:00
|
|
|
$extra_clause = 'ownerPHID in (%Ls)';
|
|
|
|
|
$argv[] = $phids;
|
|
|
|
|
break;
|
2011-02-08 10:53:59 -08:00
|
|
|
case 'created':
|
2011-02-11 10:28:37 -08:00
|
|
|
$extra_clause = 'authorPHID in (%Ls)';
|
|
|
|
|
$argv[] = $phids;
|
|
|
|
|
break;
|
2011-02-08 10:53:59 -08:00
|
|
|
case 'triage':
|
2011-02-24 14:34:58 -08:00
|
|
|
$extra_clause = 'ownerPHID in (%Ls) AND priority = %d';
|
2011-02-11 10:28:37 -08:00
|
|
|
$argv[] = $phids;
|
|
|
|
|
$argv[] = ManiphestTaskPriority::PRIORITY_TRIAGE;
|
|
|
|
|
break;
|
2011-02-09 16:29:46 -08:00
|
|
|
case 'alltriage':
|
2011-02-24 14:34:58 -08:00
|
|
|
$extra_clause = 'priority = %d';
|
2011-02-11 10:28:37 -08:00
|
|
|
$argv[] = ManiphestTaskPriority::PRIORITY_TRIAGE;
|
|
|
|
|
break;
|
2011-02-09 16:29:46 -08:00
|
|
|
case 'unassigned':
|
2011-02-11 10:28:37 -08:00
|
|
|
$extra_clause = 'ownerPHID is NULL';
|
|
|
|
|
break;
|
|
|
|
|
case 'all':
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$order = array();
|
|
|
|
|
switch ($dict['group']) {
|
|
|
|
|
case 'priority':
|
|
|
|
|
$order[] = 'priority';
|
|
|
|
|
break;
|
|
|
|
|
case 'owner':
|
|
|
|
|
$order[] = 'ownerOrdering';
|
|
|
|
|
break;
|
|
|
|
|
case 'status':
|
|
|
|
|
$order[] = 'status';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
switch ($dict['order']) {
|
|
|
|
|
case 'priority':
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$order[] = 'priority';
|
|
|
|
|
$order[] = 'dateModified';
|
2011-02-11 10:28:37 -08:00
|
|
|
break;
|
|
|
|
|
case 'created':
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$order[] = 'id';
|
2011-02-11 10:28:37 -08:00
|
|
|
break;
|
|
|
|
|
default:
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$order[] = 'dateModified';
|
2011-02-11 10:28:37 -08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$order = array_unique($order);
|
|
|
|
|
|
|
|
|
|
foreach ($order as $k => $column) {
|
|
|
|
|
switch ($column) {
|
|
|
|
|
case 'ownerOrdering':
|
|
|
|
|
$order[$k] = "{$column} ASC";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$order[$k] = "{$column} DESC";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$order = implode(', ', $order);
|
2011-02-11 10:28:37 -08:00
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$offset = (int)idx($dict, 'offset', 0);
|
|
|
|
|
$limit = (int)idx($dict, 'limit', self::DEFAULT_PAGE_SIZE);
|
2011-02-11 10:28:37 -08:00
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM %T WHERE ".
|
|
|
|
|
"({$status_clause}) AND ({$extra_clause}) ORDER BY {$order} ".
|
|
|
|
|
"LIMIT {$offset}, {$limit}";
|
|
|
|
|
|
|
|
|
|
array_unshift($argv, $task->getTableName());
|
|
|
|
|
|
|
|
|
|
$conn = $task->establishConnection('r');
|
|
|
|
|
$data = vqueryfx_all($conn, $sql, $argv);
|
|
|
|
|
|
|
|
|
|
$total_row_count = queryfx_one($conn, 'SELECT FOUND_ROWS() N');
|
|
|
|
|
$total_row_count = $total_row_count['N'];
|
|
|
|
|
|
|
|
|
|
$data = $task->loadAllFromArray($data);
|
2011-02-11 10:28:37 -08:00
|
|
|
|
|
|
|
|
$handle_phids = mpull($data, 'getOwnerPHID');
|
2011-04-11 02:03:30 -07:00
|
|
|
$handle_phids[] = $view_phid;
|
2011-02-11 10:28:37 -08:00
|
|
|
$handles = id(new PhabricatorObjectHandleData($handle_phids))
|
|
|
|
|
->loadHandles();
|
|
|
|
|
|
|
|
|
|
switch ($dict['group']) {
|
|
|
|
|
case 'priority':
|
|
|
|
|
$data = mgroup($data, 'getPriority');
|
|
|
|
|
krsort($data);
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
// If we have invalid priorities, they'll all map to "???". Merge
|
|
|
|
|
// arrays to prevent them from overwriting each other.
|
|
|
|
|
|
2011-02-11 10:28:37 -08:00
|
|
|
$out = array();
|
|
|
|
|
foreach ($data as $pri => $tasks) {
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
$out[ManiphestTaskPriority::getTaskPriorityName($pri)][] = $tasks;
|
|
|
|
|
}
|
|
|
|
|
foreach ($out as $pri => $tasks) {
|
|
|
|
|
$out[$pri] = array_mergev($tasks);
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
$data = $out;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'status':
|
|
|
|
|
$data = mgroup($data, 'getStatus');
|
|
|
|
|
ksort($data);
|
|
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
|
foreach ($data as $status => $tasks) {
|
|
|
|
|
$out[ManiphestTaskStatus::getTaskStatusFullName($status)] = $tasks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = $out;
|
|
|
|
|
break;
|
|
|
|
|
case 'owner':
|
|
|
|
|
$data = mgroup($data, 'getOwnerPHID');
|
|
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
|
foreach ($data as $phid => $tasks) {
|
|
|
|
|
if ($phid) {
|
|
|
|
|
$out[$handles[$phid]->getFullName()] = $tasks;
|
|
|
|
|
} else {
|
|
|
|
|
$out['Unassigned'] = $tasks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($out['Unassigned'])) {
|
|
|
|
|
// If any tasks are unassigned, move them to the front of the list.
|
|
|
|
|
$data = array('Unassigned' => $out['Unassigned']) + $out;
|
|
|
|
|
} else {
|
|
|
|
|
$data = $out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ksort($data);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$data = array(
|
|
|
|
|
'Tasks' => $data,
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
Allow Maniphest to scale to a massive size
Summary:
Maniphest is missing some keys and some query strategy which will make it
cumbersome to manage more than a few tens of thousands of tasks.
Test Plan:
Handily manipulated 100k-scale task groups. Maniphest takes about 250ms to
select and render pages of 1,000 tasks and has no problem paging and filtering
them, etc. We should be good to scale to multiple millions of tasks with these
changes.
Reviewed By: gc3
Reviewers: fratrik, jungejason, aran, tuomaspelkonen, gc3
Commenters: jungejason
CC: anjali, aran, epriestley, gc3, jungejason
Differential Revision: 534
2011-06-26 18:50:17 -07:00
|
|
|
return array($data, $handles, $total_row_count);
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function renderStatusLinks() {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
$statuses = array(
|
|
|
|
|
'o' => array('open' => true),
|
|
|
|
|
'c' => array('closed' => true),
|
|
|
|
|
'oc' => array('open' => true, 'closed' => true),
|
2011-02-11 10:28:37 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$status = $request->getStr('s');
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
if (empty($statuses[$status])) {
|
|
|
|
|
$status = 'o';
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$button_names = array(
|
|
|
|
|
'Open' => 'o',
|
|
|
|
|
'Closed' => 'c',
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
'All' => 'oc',
|
2011-02-11 10:28:37 -08:00
|
|
|
);
|
|
|
|
|
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
$status_links = $this->renderFilterLinks($button_names, $status, 's');
|
2011-02-11 10:28:37 -08:00
|
|
|
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
return array($statuses[$status], $status_links);
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function renderOrderLinks() {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
|
|
$order = $request->getStr('o');
|
|
|
|
|
$orders = array(
|
|
|
|
|
'u' => 'updated',
|
|
|
|
|
'c' => 'created',
|
|
|
|
|
'p' => 'priority',
|
|
|
|
|
);
|
|
|
|
|
if (empty($orders[$order])) {
|
2011-02-18 21:57:34 -08:00
|
|
|
$order = 'p';
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
$order_by = $orders[$order];
|
|
|
|
|
|
|
|
|
|
$order_names = array(
|
2011-02-18 21:57:34 -08:00
|
|
|
'Priority' => 'p',
|
2011-02-11 10:28:37 -08:00
|
|
|
'Updated' => 'u',
|
|
|
|
|
'Created' => 'c',
|
|
|
|
|
);
|
|
|
|
|
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
$order_links = $this->renderFilterLinks($order_names, $order, 'o');
|
2011-02-11 10:28:37 -08:00
|
|
|
|
|
|
|
|
return array($order_by, $order_links);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function renderGroupLinks() {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
|
|
$group = $request->getStr('g');
|
|
|
|
|
$groups = array(
|
|
|
|
|
'n' => 'none',
|
|
|
|
|
'p' => 'priority',
|
|
|
|
|
's' => 'status',
|
|
|
|
|
'o' => 'owner',
|
|
|
|
|
);
|
|
|
|
|
if (empty($groups[$group])) {
|
2011-02-18 21:57:34 -08:00
|
|
|
$group = 'p';
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
$group_by = $groups[$group];
|
|
|
|
|
|
|
|
|
|
$group_names = array(
|
|
|
|
|
'Priority' => 'p',
|
|
|
|
|
'Owner' => 'o',
|
|
|
|
|
'Status' => 's',
|
2011-02-18 21:57:34 -08:00
|
|
|
'None' => 'n',
|
2011-02-11 10:28:37 -08:00
|
|
|
);
|
|
|
|
|
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
$group_links = $this->renderFilterLinks($group_names, $group, 'g');
|
|
|
|
|
|
|
|
|
|
return array($group_by, $group_links);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function renderFilterLinks($filter_map, $selected, $uri_param) {
|
|
|
|
|
$request = $this->getRequest();
|
2011-02-11 10:28:37 -08:00
|
|
|
$uri = $request->getRequestURI();
|
|
|
|
|
|
|
|
|
|
$links = array();
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
foreach ($filter_map as $name => $value) {
|
|
|
|
|
if ($value == $selected) {
|
2011-02-11 10:28:37 -08:00
|
|
|
$more = ' toggle-selected toggle-fixed';
|
|
|
|
|
$href = null;
|
|
|
|
|
} else {
|
|
|
|
|
$more = null;
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
$href = $uri->alter($uri_param, $value);
|
2011-02-11 10:28:37 -08:00
|
|
|
}
|
|
|
|
|
$links[] = phutil_render_tag(
|
|
|
|
|
'a',
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'toggle'.$more,
|
|
|
|
|
'href' => $href,
|
|
|
|
|
),
|
|
|
|
|
$name);
|
2011-02-08 10:53:59 -08:00
|
|
|
}
|
Simplify Maniphest button filter toggle things
Summary:
Although these filters work pretty well, you still end up doing a double take
sometimes. Make the behavior simpler and more consistent by adding an "All"
button to "Open / Closed" so all three rows behave the same way (before, the top
row was toggleable but the other rows were select-only-one).
I played around with the styles a little bit too to try to make the selected
state more obvious.
sandra/anjali, let me know if this is good enough once it lands or if I should
go further in playing around with the styles and making it more clear.
Test Plan:
Filtered tasks with the various filter buttons, verified the task list
accurately represented the filters.
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, sandra, aran, epriestley, tuomaspelkonen
Differential Revision: 364
2011-05-28 13:28:56 -07:00
|
|
|
return implode("\n", $links);
|
2011-02-08 10:53:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|