mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
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:
parent
b00c28a360
commit
7b068d3e46
3 changed files with 21 additions and 19 deletions
|
@ -46,8 +46,7 @@ final class PhabricatorProjectListController
|
|||
|
||||
$query = new PhabricatorProjectQuery();
|
||||
$query->setViewer($request->getUser());
|
||||
$query->setOffset($pager->getOffset());
|
||||
$query->setLimit($pager->getPageSize() + 1);
|
||||
$query->needMembers(true);
|
||||
|
||||
$view_phid = $request->getUser()->getPHID();
|
||||
|
||||
|
@ -69,8 +68,7 @@ final class PhabricatorProjectListController
|
|||
break;
|
||||
}
|
||||
|
||||
$projects = $query->execute();
|
||||
$projects = $pager->sliceResults($projects);
|
||||
$projects = $query->executeWithOffsetPager($pager);
|
||||
|
||||
$project_phids = mpull($projects, 'getPHID');
|
||||
|
||||
|
@ -82,14 +80,6 @@ final class PhabricatorProjectListController
|
|||
$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();
|
||||
$groups = array();
|
||||
if ($project_phids) {
|
||||
|
@ -112,7 +102,7 @@ final class PhabricatorProjectListController
|
|||
$phid = $project->getPHID();
|
||||
|
||||
$profile = idx($profiles, $phid);
|
||||
$members = $edge_query->getDestinationPHIDs(array($phid));
|
||||
$members = $project->getMemberPHIDs();
|
||||
|
||||
$group = idx($groups, $phid, array());
|
||||
$task_count = count($group);
|
||||
|
|
|
@ -64,6 +64,10 @@ final class PhabricatorProjectQuery extends PhabricatorCursorPagedPolicyQuery {
|
|||
return $result->getName();
|
||||
}
|
||||
|
||||
protected function getReversePaging() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function loadPage() {
|
||||
$table = new PhabricatorProject();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
|
|
@ -34,6 +34,10 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||
return $result->getID();
|
||||
}
|
||||
|
||||
protected function getReversePaging() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function nextPage(array $page) {
|
||||
if ($this->beforeID) {
|
||||
$this->beforeID = $this->getPagingValue(head($page));
|
||||
|
@ -66,14 +70,16 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||
if ($this->beforeID) {
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
'%Q > %s',
|
||||
'%Q %Q %s',
|
||||
$this->getPagingColumn(),
|
||||
$this->getReversePaging() ? '<' : '>',
|
||||
$this->beforeID);
|
||||
} else if ($this->afterID) {
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
'%Q < %s',
|
||||
'%Q %Q %s',
|
||||
$this->getPagingColumn(),
|
||||
$this->getReversePaging() ? '>' : '<',
|
||||
$this->afterID);
|
||||
}
|
||||
|
||||
|
@ -84,13 +90,15 @@ abstract class PhabricatorCursorPagedPolicyQuery
|
|||
if ($this->beforeID) {
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
'ORDER BY %Q ASC',
|
||||
$this->getPagingColumn());
|
||||
'ORDER BY %Q %Q',
|
||||
$this->getPagingColumn(),
|
||||
$this->getReversePaging() ? 'DESC' : 'ASC');
|
||||
} else {
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
'ORDER BY %Q DESC',
|
||||
$this->getPagingColumn());
|
||||
'ORDER BY %Q %Q',
|
||||
$this->getPagingColumn(),
|
||||
$this->getReversePaging() ? 'ASC' : 'DESC');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue