From 0900ffe9cb3e3d9fffc67ed4ba63344f16ec6676 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 7 Apr 2016 12:10:56 -0700 Subject: [PATCH] Support sorting countdowns by end date Summary: Fixes T5813, while I'm in here... Test Plan: Sorted stuff by end date. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5813 Differential Revision: https://secure.phabricator.com/D15657 --- .../query/PhabricatorCountdownQuery.php | 31 +++++++++++++++++++ .../PhabricatorCountdownSearchEngine.php | 20 ++++++------ .../storage/PhabricatorCountdown.php | 8 +++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/applications/countdown/query/PhabricatorCountdownQuery.php b/src/applications/countdown/query/PhabricatorCountdownQuery.php index 17fde126f8..e6c410ee49 100644 --- a/src/applications/countdown/query/PhabricatorCountdownQuery.php +++ b/src/applications/countdown/query/PhabricatorCountdownQuery.php @@ -74,4 +74,35 @@ final class PhabricatorCountdownQuery return 'PhabricatorCountdownApplication'; } + public function getBuiltinOrders() { + return array( + 'ending' => array( + 'vector' => array('-epoch', '-id'), + 'name' => pht('End Date (Past to Future)'), + ), + 'unending' => array( + 'vector' => array('epoch', 'id'), + 'name' => pht('End Date (Future to Past)'), + ), + ) + parent::getBuiltinOrders(); + } + + public function getOrderableColumns() { + return array( + 'epoch' => array( + 'table' => $this->getPrimaryTableAlias(), + 'column' => 'epoch', + 'type' => 'int', + ), + ) + parent::getOrderableColumns(); + } + + protected function getPagingValueMap($cursor, array $keys) { + $countdown = $this->loadCursorObject($cursor); + return array( + 'epoch' => $countdown->getEpoch(), + 'id' => $countdown->getID(), + ); + } + } diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index 79b329385a..93aec9a037 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -30,20 +30,18 @@ final class PhabricatorCountdownSearchEngine } protected function buildCustomSearchFields() { - return array( - id(new PhabricatorUsersSearchField()) - ->setLabel(pht('Authors')) - ->setKey('authorPHIDs') - ->setAliases(array('author', 'authors')), - - id(new PhabricatorSearchCheckboxesField()) - ->setKey('upcoming') - ->setOptions(array( + id(new PhabricatorUsersSearchField()) + ->setLabel(pht('Authors')) + ->setKey('authorPHIDs') + ->setAliases(array('author', 'authors')), + id(new PhabricatorSearchCheckboxesField()) + ->setKey('upcoming') + ->setOptions( + array( 'upcoming' => pht('Show only upcoming countdowns.'), )), - ); - + ); } protected function getURI($path) { diff --git a/src/applications/countdown/storage/PhabricatorCountdown.php b/src/applications/countdown/storage/PhabricatorCountdown.php index 1a985b0b83..ad9b1b33aa 100644 --- a/src/applications/countdown/storage/PhabricatorCountdown.php +++ b/src/applications/countdown/storage/PhabricatorCountdown.php @@ -46,6 +46,14 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO 'description' => 'text', 'mailKey' => 'bytes20', ), + self::CONFIG_KEY_SCHEMA => array( + 'key_epoch' => array( + 'columns' => array('epoch'), + ), + 'key_author' => array( + 'columns' => array('authorPHID', 'epoch'), + ), + ), ) + parent::getConfiguration(); }