Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15368120
D12362.id29685.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12362.id29685.diff
View Options
diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php
--- a/src/applications/differential/query/DifferentialRevisionQuery.php
+++ b/src/applications/differential/query/DifferentialRevisionQuery.php
@@ -41,7 +41,6 @@
private $updatedEpochMin;
private $updatedEpochMax;
- private $order = 'order-modified';
const ORDER_MODIFIED = 'order-modified';
const ORDER_CREATED = 'order-created';
@@ -261,7 +260,17 @@
* @task config
*/
public function setOrder($order_constant) {
- $this->order = $order_constant;
+ switch ($order_constant) {
+ case self::ORDER_CREATED:
+ $this->setOrderVector(array('id'));
+ break;
+ case self::ORDER_MODIFIED:
+ $this->setOrderVector(array('updated', 'id'));
+ break;
+ default:
+ throw new Exception(pht('Unknown order "%s".', $order_constant));
+ }
+
return $this;
}
@@ -853,72 +862,34 @@
}
}
- protected function buildPagingClause(AphrontDatabaseConnection $conn_r) {
- $default = parent::buildPagingClause($conn_r);
-
- $before_id = $this->getBeforeID();
- $after_id = $this->getAfterID();
-
- if (!$before_id && !$after_id) {
- return $default;
- }
-
- if ($before_id) {
- $cursor = $this->loadCursorObject($before_id);
- } else {
- $cursor = $this->loadCursorObject($after_id);
- }
-
- if (!$cursor) {
- return null;
- }
-
- $columns = array();
+ protected function getDefaultOrderVector() {
+ return array('updated', 'id');
+ }
- switch ($this->order) {
- case self::ORDER_CREATED:
- return $default;
- case self::ORDER_MODIFIED:
- $columns[] = array(
- 'table' => 'r',
- 'column' => 'dateModified',
- 'value' => $cursor->getDateModified(),
- 'type' => 'int',
- );
- break;
- }
+ public function getOrderableColumns() {
+ $primary = ($this->buildingGlobalOrder ? null : 'r');
- $columns[] = array(
- 'table' => 'r',
- 'column' => 'id',
- 'value' => $cursor->getID(),
- 'type' => 'int',
+ return array(
+ 'id' => array(
+ 'table' => $primary,
+ 'column' => 'id',
+ 'type' => 'int',
+ 'unique' => true,
+ ),
+ 'updated' => array(
+ 'table' => $primary,
+ 'column' => 'dateModified',
+ 'type' => 'int',
+ ),
);
-
- return $this->buildPagingClauseFromMultipleColumns(
- $conn_r,
- $columns,
- array(
- 'reversed' => (bool)($before_id xor $this->getReversePaging()),
- ));
}
- protected function getPagingColumn() {
- $is_global = $this->buildingGlobalOrder;
- switch ($this->order) {
- case self::ORDER_MODIFIED:
- if ($is_global) {
- return 'dateModified';
- }
- return 'r.dateModified';
- case self::ORDER_CREATED:
- if ($is_global) {
- return 'id';
- }
- return 'r.id';
- default:
- throw new Exception("Unknown query order constant '{$this->order}'.");
- }
+ protected function getPagingValueMap($cursor, array $keys) {
+ $revision = $this->loadCursorObject($cursor);
+ return array(
+ 'id' => $revision->getID(),
+ 'updated' => $revision->getDateModified(),
+ );
}
private function loadRelationships($conn_r, array $revisions) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 11:58 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7597812
Default Alt Text
D12362.id29685.diff (3 KB)
Attached To
Mode
D12362: Modernize Differential paging/ordering
Attached
Detach File
Event Timeline
Log In to Comment