Page MenuHomePhabricator

D12362.diff
No OneTemporary

D12362.diff

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

Mime Type
text/plain
Expires
Thu, May 16, 1:17 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6289568
Default Alt Text
D12362.diff (3 KB)

Event Timeline