From d496f4d28c7c1e900c71e7662278c876fe366736 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 11 Apr 2015 19:07:28 -0700 Subject: [PATCH] Modernize ProjectQuery paging/ordering Summary: Ref T7803. Move ProjectQuery off getReversePaging() / getPagingColumn() and onto order vectors. Test Plan: Set project page size to 3 and paged back and forth. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7803 Differential Revision: https://secure.phabricator.com/D12357 --- .../project/query/PhabricatorProjectQuery.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php index 62db2b2aed..89d1f31dba 100644 --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -95,18 +95,32 @@ final class PhabricatorProjectQuery return $this; } - protected function getPagingColumn() { - return 'name'; + protected function getDefaultOrderVector() { + return array('name'); + } + + public function getOrderableColumns() { + return array( + 'name' => array( + 'table' => $this->getPrimaryTableAlias(), + 'column' => 'name', + 'reverse' => true, + 'type' => 'string', + 'unique' => true, + ), + ); + } + + protected function getPagingValueMap($cursor, array $keys) { + return array( + 'name' => $cursor, + ); } protected function getPagingValue($result) { return $result->getName(); } - protected function getReversePaging() { - return true; - } - protected function loadPage() { $table = new PhabricatorProject(); $conn_r = $table->establishConnection('r');