1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

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
This commit is contained in:
epriestley 2015-04-11 19:38:03 -07:00
parent a4a198342e
commit 8bd1ab9d13
2 changed files with 52 additions and 13 deletions

View file

@ -90,10 +90,26 @@ final class PhabricatorFeedQuery
} }
} }
protected function getPagingColumn() { protected function getDefaultOrderVector() {
return ($this->filterPHIDs return array('key');
? 'ref.chronologicalKey' }
: 'story.chronologicalKey');
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) { protected function getPagingValue($item) {

View file

@ -3,9 +3,15 @@
final class PhluxVariableQuery final class PhluxVariableQuery
extends PhabricatorCursorPagedPolicyAwareQuery { extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
private $keys; private $keys;
private $phids; private $phids;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withPHIDs(array $phids) { public function withPHIDs(array $phids) {
$this->phids = $phids; $this->phids = $phids;
return $this; return $this;
@ -34,35 +40,52 @@ final class PhluxVariableQuery
private function buildWhereClause(AphrontDatabaseConnection $conn_r) { private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array(); $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( $where[] = qsprintf(
$conn_r, $conn_r,
'variableKey IN (%Ls)', 'variableKey IN (%Ls)',
$this->keys); $this->keys);
} }
if ($this->phids) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn_r,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where); return $this->formatWhereClause($where);
} }
protected function getPagingColumn() { protected function getDefaultOrderVector() {
return 'variableKey'; return array('key');
} }
protected function getPagingValue($result) { public function getOrderableColumns() {
return $result->getVariableKey(); return array(
'key' => array(
'column' => 'variableKey',
'type' => 'string',
'reverse' => true,
'unique' => true,
),
);
} }
protected function getReversePaging() { protected function getPagingValueMap($cursor, array $keys) {
return true; $object = $this->loadCursorObject($cursor);
return array(
'key' => $object->getVariableKey(),
);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {