diff --git a/src/applications/meta/query/PhabricatorApplicationQuery.php b/src/applications/meta/query/PhabricatorApplicationQuery.php --- a/src/applications/meta/query/PhabricatorApplicationQuery.php +++ b/src/applications/meta/query/PhabricatorApplicationQuery.php @@ -170,10 +170,4 @@ return null; } - protected function getResultCursor($object) { - // TODO: This won't work, but doesn't matter until we write more than 100 - // applications. Since we only have about 70, just avoid fataling for now. - return null; - } - } diff --git a/src/applications/notification/query/PhabricatorNotificationQuery.php b/src/applications/notification/query/PhabricatorNotificationQuery.php --- a/src/applications/notification/query/PhabricatorNotificationQuery.php +++ b/src/applications/notification/query/PhabricatorNotificationQuery.php @@ -53,10 +53,10 @@ $data = queryfx_all( $conn, - 'SELECT story.*, notif.hasViewed FROM %R notif - JOIN %R story ON notif.chronologicalKey = story.chronologicalKey + 'SELECT story.*, notification.hasViewed FROM %R notification + JOIN %R story ON notification.chronologicalKey = story.chronologicalKey %Q - ORDER BY notif.chronologicalKey DESC + ORDER BY notification.chronologicalKey DESC %Q', $notification_table, $story_table, @@ -82,21 +82,21 @@ if ($this->userPHIDs !== null) { $where[] = qsprintf( $conn, - 'notif.userPHID IN (%Ls)', + 'notification.userPHID IN (%Ls)', $this->userPHIDs); } if ($this->unread !== null) { $where[] = qsprintf( $conn, - 'notif.hasViewed = %d', + 'notification.hasViewed = %d', (int)!$this->unread); } if ($this->keys !== null) { $where[] = qsprintf( $conn, - 'notif.chronologicalKey IN (%Ls)', + 'notification.chronologicalKey IN (%Ls)', $this->keys); } @@ -113,8 +113,53 @@ return $stories; } - protected function getResultCursor($item) { - return $item->getChronologicalKey(); + protected function getDefaultOrderVector() { + return array('key'); + } + + public function getBuiltinOrders() { + return array( + 'newest' => array( + 'vector' => array('key'), + 'name' => pht('Creation (Newest First)'), + 'aliases' => array('created'), + ), + 'oldest' => array( + 'vector' => array('-key'), + 'name' => pht('Creation (Oldest First)'), + ), + ); + } + + public function getOrderableColumns() { + return array( + 'key' => array( + 'table' => 'notification', + 'column' => 'chronologicalKey', + 'type' => 'string', + 'unique' => true, + ), + ); + } + + protected function applyExternalCursorConstraintsToQuery( + PhabricatorCursorPagedPolicyAwareQuery $subquery, + $cursor) { + $subquery->withKeys(array($cursor)); + } + + protected function newExternalCursorStringForResult($object) { + return $object->getChronologicalKey(); + } + + protected function newPagingMapFromPartialObject($object) { + return array( + 'key' => $object->getChronologicalKey(), + ); + } + + protected function getPrimaryTableAlias() { + return 'notification'; } public function getQueryApplicationClass() { diff --git a/src/applications/notification/query/PhabricatorNotificationSearchEngine.php b/src/applications/notification/query/PhabricatorNotificationSearchEngine.php --- a/src/applications/notification/query/PhabricatorNotificationSearchEngine.php +++ b/src/applications/notification/query/PhabricatorNotificationSearchEngine.php @@ -134,8 +134,4 @@ return $result; } - public function shouldUseOffsetPaging() { - return true; - } - } diff --git a/src/applications/transactions/query/PhabricatorEditEngineQuery.php b/src/applications/transactions/query/PhabricatorEditEngineQuery.php --- a/src/applications/transactions/query/PhabricatorEditEngineQuery.php +++ b/src/applications/transactions/query/PhabricatorEditEngineQuery.php @@ -46,8 +46,4 @@ return 'PhabricatorTransactionsApplication'; } - protected function getResultCursor($object) { - return null; - } - }