1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00

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
This commit is contained in:
epriestley 2013-09-25 13:44:36 -07:00
parent 3a87a95e11
commit 36343600c5
2 changed files with 3 additions and 81 deletions

View file

@ -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(

View file

@ -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(
'<div class="phabricator-profile-info-group profile-wrap-responsive">
<h1 class="phabricator-profile-info-header">%s</h1>'.
@ -184,7 +180,7 @@ final class PhabricatorProjectProfileController
'%s'.
'</div>
</div>',
pht('Open Tasks (%s)', $open),
pht('Open Tasks'),
$task_list);
return $content;