From 8bd1ab9d136f093a54f86aa735e6500e23a6f77f Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 11 Apr 2015 19:38:03 -0700 Subject: [PATCH] Modernize Feed and Phlux ordering/paging Summary: Ref T7803. Move these off getReversePaging() / getPagingColumn(). Test Plan: Paged through Phlux and Feed. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7803 Differential Revision: https://secure.phabricator.com/D12359 --- .../feed/query/PhabricatorFeedQuery.php | 24 +++++++++-- .../phlux/query/PhluxVariableQuery.php | 41 +++++++++++++++---- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/applications/feed/query/PhabricatorFeedQuery.php b/src/applications/feed/query/PhabricatorFeedQuery.php index 7e610e4483..a0851aeca0 100644 --- a/src/applications/feed/query/PhabricatorFeedQuery.php +++ b/src/applications/feed/query/PhabricatorFeedQuery.php @@ -90,10 +90,26 @@ final class PhabricatorFeedQuery } } - protected function getPagingColumn() { - return ($this->filterPHIDs - ? 'ref.chronologicalKey' - : 'story.chronologicalKey'); + protected function getDefaultOrderVector() { + return array('key'); + } + + public function getOrderableColumns() { + $table = ($this->filterPHIDs ? 'ref' : 'story'); + return array( + 'key' => array( + 'table' => $table, + 'column' => 'chronologicalKey', + 'type' => 'int', + 'unique' => true, + ), + ); + } + + protected function getPagingValueMap($cursor, array $keys) { + return array( + 'key' => $cursor, + ); } protected function getPagingValue($item) { diff --git a/src/applications/phlux/query/PhluxVariableQuery.php b/src/applications/phlux/query/PhluxVariableQuery.php index 190b677934..3439ee1d8b 100644 --- a/src/applications/phlux/query/PhluxVariableQuery.php +++ b/src/applications/phlux/query/PhluxVariableQuery.php @@ -3,9 +3,15 @@ final class PhluxVariableQuery extends PhabricatorCursorPagedPolicyAwareQuery { + private $ids; private $keys; private $phids; + public function withIDs(array $ids) { + $this->ids = $ids; + return $this; + } + public function withPHIDs(array $phids) { $this->phids = $phids; return $this; @@ -34,35 +40,52 @@ final class PhluxVariableQuery private function buildWhereClause(AphrontDatabaseConnection $conn_r) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + if ($this->ids !== null) { + $where[] = qsprintf( + $conn_r, + 'id IN (%Ld)', + $this->ids); + } - if ($this->keys) { + if ($this->keys !== null) { $where[] = qsprintf( $conn_r, 'variableKey IN (%Ls)', $this->keys); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( $conn_r, 'phid IN (%Ls)', $this->phids); } + $where[] = $this->buildPagingClause($conn_r); + return $this->formatWhereClause($where); } - protected function getPagingColumn() { - return 'variableKey'; + protected function getDefaultOrderVector() { + return array('key'); } - protected function getPagingValue($result) { - return $result->getVariableKey(); + public function getOrderableColumns() { + return array( + 'key' => array( + 'column' => 'variableKey', + 'type' => 'string', + 'reverse' => true, + 'unique' => true, + ), + ); } - protected function getReversePaging() { - return true; + protected function getPagingValueMap($cursor, array $keys) { + $object = $this->loadCursorObject($cursor); + return array( + 'key' => $object->getVariableKey(), + ); } public function getQueryApplicationClass() {