diff --git a/src/applications/feed/query/PhabricatorFeedQuery.php b/src/applications/feed/query/PhabricatorFeedQuery.php --- a/src/applications/feed/query/PhabricatorFeedQuery.php +++ b/src/applications/feed/query/PhabricatorFeedQuery.php @@ -90,10 +90,26 @@ } } - 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 --- 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 @@ 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() {