1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Completely implement cursor paging in Maniphest

Summary: Ref T2625. Fixes user and project paging. Adds visibility-aware project group filtering.

Test Plan: Set page size very small and paged forward and backward in Maniphest, particularly with "Assigned" and "Project" group-by filters.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6973
This commit is contained in:
epriestley 2013-09-13 07:32:57 -07:00
parent 5062abc534
commit 62e66e3cf6

View file

@ -324,6 +324,26 @@ final class ManiphestTaskQuery
return $tasks; return $tasks;
} }
protected function willFilterPage(array $tasks) {
if ($this->groupBy == self::GROUP_PROJECT) {
// We should only return project groups which the user can actually see.
$project_phids = mpull($tasks, 'getGroupByProjectPHID');
$projects = id(new PhabricatorProjectQuery())
->setViewer($this->getViewer())
->withPHIDs($project_phids)
->execute();
$projects = mpull($projects, null, 'getPHID');
foreach ($tasks as $key => $task) {
if (empty($projects[$task->getGroupByProjectPHID()])) {
unset($tasks[$key]);
}
}
}
return $tasks;
}
private function buildTaskIDsWhereClause(AphrontDatabaseConnection $conn) { private function buildTaskIDsWhereClause(AphrontDatabaseConnection $conn) {
if (!$this->taskIDs) { if (!$this->taskIDs) {
return null; return null;
@ -774,13 +794,11 @@ final class ManiphestTaskQuery
case self::GROUP_PRIORITY: case self::GROUP_PRIORITY:
return $id.'.'.$result->getPriority(); return $id.'.'.$result->getPriority();
case self::GROUP_OWNER: case self::GROUP_OWNER:
// TODO: Make this actually work. return rtrim($id.'.'.$result->getOwnerPHID(), '.');
return $id.'.AUTHORNAME';
case self::GROUP_STATUS: case self::GROUP_STATUS:
return $id.'.'.$result->getStatus(); return $id.'.'.$result->getStatus();
case self::GROUP_PROJECT: case self::GROUP_PROJECT:
// TODO: Make this actually work. return rtrim($id.'.'.$result->getGroupByProjectPHID(), '.');
return $id.'.PROJNAME';
default: default:
throw new Exception("Unknown group query '{$this->groupBy}'!"); throw new Exception("Unknown group query '{$this->groupBy}'!");
} }
@ -820,11 +838,25 @@ final class ManiphestTaskQuery
break; break;
case self::GROUP_OWNER: case self::GROUP_OWNER:
$columns[] = array( $columns[] = array(
'name' => 'task.ownerOrdering', 'name' => '(task.ownerOrdering IS NULL)',
'value' => $group_id, 'value' => (int)(strlen($group_id) ? 0 : 1),
'type' => 'string', 'type' => 'int',
'reverse' => true,
); );
if ($group_id) {
$paging_users = id(new PhabricatorPeopleQuery())
->setViewer($this->getViewer())
->withPHIDs(array($group_id))
->execute();
if (!$paging_users) {
return null;
}
$columns[] = array(
'name' => 'task.ownerOrdering',
'value' => head($paging_users)->getUsername(),
'type' => 'string',
'reverse' => true,
);
}
break; break;
case self::GROUP_STATUS: case self::GROUP_STATUS:
$columns[] = array( $columns[] = array(
@ -839,10 +871,17 @@ final class ManiphestTaskQuery
'value' => (int)(strlen($group_id) ? 0 : 1), 'value' => (int)(strlen($group_id) ? 0 : 1),
'type' => 'int', 'type' => 'int',
); );
if (strlen($group_id)) { if ($group_id) {
$paging_projects = id(new PhabricatorProjectQuery())
->setViewer($this->getViewer())
->withPHIDs(array($group_id))
->execute();
if (!$paging_projects) {
return null;
}
$columns[] = array( $columns[] = array(
'name' => 'projectGroupName.indexedObjectName', 'name' => 'projectGroupName.indexedObjectName',
'value' => $group_id, 'value' => head($paging_projects)->getName(),
'type' => 'string', 'type' => 'string',
'reverse' => true, 'reverse' => true,
); );