From 36343600c5c7b5a10852cc008baaa3b98387b849 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 25 Sep 2013 13:44:36 -0700 Subject: [PATCH] Remove obsolete code from ManiphestTaskQuery Summary: Ref T603. Cleans up some obsolete stuff here: - We no longer ever query by min/max priority (instead, `withPriorities(...)`). - A parent class provides limit/offset. - Result count is no longer reliable with policies. We could do "about X tasks" or something, but just drop it for now. There's only one remaining callsite anyway. Test Plan: - `grep` - Viewed task list. - Viewed a project page. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7121 --- .../maniphest/query/ManiphestTaskQuery.php | 76 +------------------ .../PhabricatorProjectProfileController.php | 8 +- 2 files changed, 3 insertions(+), 81 deletions(-) diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 67fd4873d4..ccda6c0122 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -36,13 +36,8 @@ final class ManiphestTaskQuery const STATUS_DUPLICATE = 'status-duplicate'; private $statuses; - - private $priority = null; private $priorities; - private $minPriority = null; - private $maxPriority = null; - private $groupBy = 'group-none'; const GROUP_NONE = 'group-none'; const GROUP_PRIORITY = 'group-priority'; @@ -56,14 +51,8 @@ final class ManiphestTaskQuery const ORDER_MODIFIED = 'order-modified'; const ORDER_TITLE = 'order-title'; - private $limit = null; const DEFAULT_PAGE_SIZE = 1000; - private $offset = 0; - private $calculateRows = false; - - private $rowCount = null; - public function withAuthors(array $authors) { $this->authorPHIDs = $authors; return $this; @@ -119,22 +108,11 @@ final class ManiphestTaskQuery return $this; } - public function withPriority($priority) { - $this->priority = $priority; - return $this; - } - public function withPriorities(array $priorities) { $this->priorities = $priorities; return $this; } - public function withPrioritiesBetween($min, $max) { - $this->minPriority = $min; - $this->maxPriority = $max; - return $this; - } - public function withSubscribers(array $subscribers) { $this->subscriberPHIDs = $subscribers; return $this; @@ -155,20 +133,6 @@ final class ManiphestTaskQuery return $this; } - public function setCalculateRows($calculate_rows) { - $this->calculateRows = $calculate_rows; - return $this; - } - - public function getRowCount() { - if ($this->rowCount === null) { - throw new Exception( - "You must execute a query with setCalculateRows() before you can ". - "retrieve a row count."); - } - return $this->rowCount; - } - public function withAnyProjects(array $projects) { $this->anyProjectPHIDs = $projects; return $this; @@ -200,22 +164,11 @@ final class ManiphestTaskQuery $task_dao = new ManiphestTask(); $conn = $task_dao->establishConnection('r'); - if ($this->calculateRows) { - $calc = 'SQL_CALC_FOUND_ROWS'; - - // Make sure we end up in the right state if we throw a - // PhabricatorEmptyQueryException. - $this->rowCount = 0; - } else { - $calc = ''; - } - $where = array(); $where[] = $this->buildTaskIDsWhereClause($conn); $where[] = $this->buildTaskPHIDsWhereClause($conn); $where[] = $this->buildStatusWhereClause($conn); $where[] = $this->buildStatusesWhereClause($conn); - $where[] = $this->buildPriorityWhereClause($conn); $where[] = $this->buildPrioritiesWhereClause($conn); $where[] = $this->buildAuthorWhereClause($conn); $where[] = $this->buildOwnerWhereClause($conn); @@ -277,8 +230,7 @@ final class ManiphestTaskQuery $rows = queryfx_all( $conn, - 'SELECT %Q task.* %Q %Q FROM %T task %Q %Q %Q %Q %Q %Q', - $calc, + 'SELECT task.* %Q %Q FROM %T task %Q %Q %Q %Q %Q %Q', $count, $group_column, $task_dao->getTableName(), @@ -289,15 +241,6 @@ final class ManiphestTaskQuery $order, $this->buildLimitClause($conn)); - if ($this->calculateRows) { - $count = queryfx_one( - $conn, - 'SELECT FOUND_ROWS() N'); - $this->rowCount = $count['N']; - } else { - $this->rowCount = null; - } - switch ($this->groupBy) { case self::GROUP_PROJECT: $data = ipull($rows, null, 'id'); @@ -405,23 +348,6 @@ final class ManiphestTaskQuery return null; } - private function buildPriorityWhereClause(AphrontDatabaseConnection $conn) { - if ($this->priority !== null) { - return qsprintf( - $conn, - 'priority = %d', - $this->priority); - } elseif ($this->minPriority !== null && $this->maxPriority !== null) { - return qsprintf( - $conn, - 'priority >= %d AND priority <= %d', - $this->minPriority, - $this->maxPriority); - } - - return null; - } - private function buildPrioritiesWhereClause(AphrontDatabaseConnection $conn) { if ($this->priorities) { return qsprintf( diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index 48ae73d481..e8a25d1b49 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -158,10 +158,8 @@ final class PhabricatorProjectProfileController ->withAnyProjects(array($project->getPHID())) ->withStatus(ManiphestTaskQuery::STATUS_OPEN) ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) - ->setLimit(10) - ->setCalculateRows(true); + ->setLimit(10); $tasks = $query->execute(); - $count = $query->getRowCount(); $phids = mpull($tasks, 'getOwnerPHID'); $phids = array_merge( @@ -175,8 +173,6 @@ final class PhabricatorProjectProfileController $task_list->setTasks($tasks); $task_list->setHandles($handles); - $open = number_format($count); - $content = hsprintf( '

%s

'. @@ -184,7 +180,7 @@ final class PhabricatorProjectProfileController '%s'. '
', - pht('Open Tasks (%s)', $open), + pht('Open Tasks'), $task_list); return $content;