Reverse project paging order
Summary: Currently, we're showing projets in reverse order (Z..A) because most cursor pagers go from high IDs to low IDs. Allow sequence to be reversed; reverse it. Also simplify some query/paging stuff. Test Plan: Set page size to 1, paged back and forth. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D3221
This commit is contained in:
@@ -46,8 +46,7 @@ final class PhabricatorProjectListController
|
|||||||
|
|
||||||
$query = new PhabricatorProjectQuery();
|
$query = new PhabricatorProjectQuery();
|
||||||
$query->setViewer($request->getUser());
|
$query->setViewer($request->getUser());
|
||||||
$query->setOffset($pager->getOffset());
|
$query->needMembers(true);
|
||||||
$query->setLimit($pager->getPageSize() + 1);
|
|
||||||
|
|
||||||
$view_phid = $request->getUser()->getPHID();
|
$view_phid = $request->getUser()->getPHID();
|
||||||
|
|
||||||
@@ -69,8 +68,7 @@ final class PhabricatorProjectListController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$projects = $query->execute();
|
$projects = $query->executeWithOffsetPager($pager);
|
||||||
$projects = $pager->sliceResults($projects);
|
|
||||||
|
|
||||||
$project_phids = mpull($projects, 'getPHID');
|
$project_phids = mpull($projects, 'getPHID');
|
||||||
|
|
||||||
@@ -82,14 +80,6 @@ final class PhabricatorProjectListController
|
|||||||
$profiles = mpull($profiles, null, 'getProjectPHID');
|
$profiles = mpull($profiles, null, 'getProjectPHID');
|
||||||
}
|
}
|
||||||
|
|
||||||
$edge_query = new PhabricatorEdgeQuery();
|
|
||||||
if ($projects) {
|
|
||||||
$edge_query
|
|
||||||
->withSourcePHIDs($project_phids)
|
|
||||||
->withEdgeTypes(array(PhabricatorEdgeConfig::TYPE_PROJ_MEMBER))
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tasks = array();
|
$tasks = array();
|
||||||
$groups = array();
|
$groups = array();
|
||||||
if ($project_phids) {
|
if ($project_phids) {
|
||||||
@@ -112,7 +102,7 @@ final class PhabricatorProjectListController
|
|||||||
$phid = $project->getPHID();
|
$phid = $project->getPHID();
|
||||||
|
|
||||||
$profile = idx($profiles, $phid);
|
$profile = idx($profiles, $phid);
|
||||||
$members = $edge_query->getDestinationPHIDs(array($phid));
|
$members = $project->getMemberPHIDs();
|
||||||
|
|
||||||
$group = idx($groups, $phid, array());
|
$group = idx($groups, $phid, array());
|
||||||
$task_count = count($group);
|
$task_count = count($group);
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ final class PhabricatorProjectQuery extends PhabricatorCursorPagedPolicyQuery {
|
|||||||
return $result->getName();
|
return $result->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getReversePaging() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function loadPage() {
|
public function loadPage() {
|
||||||
$table = new PhabricatorProject();
|
$table = new PhabricatorProject();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn_r = $table->establishConnection('r');
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||||||
return $result->getID();
|
return $result->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getReversePaging() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected function nextPage(array $page) {
|
protected function nextPage(array $page) {
|
||||||
if ($this->beforeID) {
|
if ($this->beforeID) {
|
||||||
$this->beforeID = $this->getPagingValue(head($page));
|
$this->beforeID = $this->getPagingValue(head($page));
|
||||||
@@ -66,14 +70,16 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||||||
if ($this->beforeID) {
|
if ($this->beforeID) {
|
||||||
return qsprintf(
|
return qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'%Q > %s',
|
'%Q %Q %s',
|
||||||
$this->getPagingColumn(),
|
$this->getPagingColumn(),
|
||||||
|
$this->getReversePaging() ? '<' : '>',
|
||||||
$this->beforeID);
|
$this->beforeID);
|
||||||
} else if ($this->afterID) {
|
} else if ($this->afterID) {
|
||||||
return qsprintf(
|
return qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'%Q < %s',
|
'%Q %Q %s',
|
||||||
$this->getPagingColumn(),
|
$this->getPagingColumn(),
|
||||||
|
$this->getReversePaging() ? '>' : '<',
|
||||||
$this->afterID);
|
$this->afterID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,13 +90,15 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||||||
if ($this->beforeID) {
|
if ($this->beforeID) {
|
||||||
return qsprintf(
|
return qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'ORDER BY %Q ASC',
|
'ORDER BY %Q %Q',
|
||||||
$this->getPagingColumn());
|
$this->getPagingColumn(),
|
||||||
|
$this->getReversePaging() ? 'DESC' : 'ASC');
|
||||||
} else {
|
} else {
|
||||||
return qsprintf(
|
return qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'ORDER BY %Q DESC',
|
'ORDER BY %Q %Q',
|
||||||
$this->getPagingColumn());
|
$this->getPagingColumn(),
|
||||||
|
$this->getReversePaging() ? 'ASC' : 'DESC');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user