mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
a4a198342e
commit
8bd1ab9d13
2 changed files with 52 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue