Page MenuHomePhabricator

D15560.diff
No OneTemporary

D15560.diff

diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php
--- a/src/applications/maniphest/query/ManiphestTaskQuery.php
+++ b/src/applications/maniphest/query/ManiphestTaskQuery.php
@@ -329,7 +329,6 @@
$where = parent::buildWhereClauseParts($conn);
$where[] = $this->buildStatusWhereClause($conn);
- $where[] = $this->buildDependenciesWhereClause($conn);
$where[] = $this->buildOwnerWhereClause($conn);
$where[] = $this->buildFullTextWhereClause($conn);
@@ -513,42 +512,6 @@
$fulltext_results);
}
- private function buildDependenciesWhereClause(
- AphrontDatabaseConnection $conn) {
-
- if (!$this->shouldJoinBlockedTasks() &&
- !$this->shouldJoinBlockingTasks()) {
- return null;
- }
-
- $parts = array();
- if ($this->blockingTasks === true) {
- $parts[] = qsprintf(
- $conn,
- 'blocking.dst IS NOT NULL AND blockingtask.status IN (%Ls)',
- ManiphestTaskStatus::getOpenStatusConstants());
- } else if ($this->blockingTasks === false) {
- $parts[] = qsprintf(
- $conn,
- 'blocking.dst IS NULL OR blockingtask.status NOT IN (%Ls)',
- ManiphestTaskStatus::getOpenStatusConstants());
- }
-
- if ($this->blockedTasks === true) {
- $parts[] = qsprintf(
- $conn,
- 'blocked.dst IS NOT NULL AND blockedtask.status IN (%Ls)',
- ManiphestTaskStatus::getOpenStatusConstants());
- } else if ($this->blockedTasks === false) {
- $parts[] = qsprintf(
- $conn,
- 'blocked.dst IS NULL OR blockedtask.status NOT IN (%Ls)',
- ManiphestTaskStatus::getOpenStatusConstants());
- }
-
- return '('.implode(') OR (', $parts).')';
- }
-
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn_r) {
$edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE;
@@ -559,20 +522,24 @@
$conn_r,
'LEFT JOIN %T blocking ON blocking.src = task.phid '.
'AND blocking.type = %d '.
- 'LEFT JOIN %T blockingtask ON blocking.dst = blockingtask.phid',
+ 'LEFT JOIN %T blockingtask ON blocking.dst = blockingtask.phid '.
+ 'AND blockingtask.status IN (%Ls)',
$edge_table,
ManiphestTaskDependedOnByTaskEdgeType::EDGECONST,
- id(new ManiphestTask())->getTableName());
+ id(new ManiphestTask())->getTableName(),
+ ManiphestTaskStatus::getOpenStatusConstants());
}
if ($this->shouldJoinBlockedTasks()) {
$joins[] = qsprintf(
$conn_r,
'LEFT JOIN %T blocked ON blocked.src = task.phid '.
'AND blocked.type = %d '.
- 'LEFT JOIN %T blockedtask ON blocked.dst = blockedtask.phid',
+ 'LEFT JOIN %T blockedtask ON blocked.dst = blockedtask.phid '.
+ 'AND blockedtask.status IN (%Ls)',
$edge_table,
ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
- id(new ManiphestTask())->getTableName());
+ id(new ManiphestTask())->getTableName(),
+ ManiphestTaskStatus::getOpenStatusConstants());
}
if ($this->subscriberPHIDs !== null) {
@@ -687,6 +654,38 @@
return array_mergev($phids);
}
+ protected function buildHavingClauseParts(AphrontDatabaseConnection $conn) {
+ $having = parent::buildHavingClauseParts($conn);
+
+ $having[] = $this->buildDependenciesHavingClause($conn);
+
+ return $having;
+ }
+
+ private function buildDependenciesHavingClause(
+ AphrontDatabaseConnection $conn) {
+
+ if (!$this->shouldJoinBlockedTasks() &&
+ !$this->shouldJoinBlockingTasks()) {
+ return null;
+ }
+
+ $parts = array();
+ if ($this->blockingTasks === true) {
+ $parts[] = 'COUNT(blockingtask.phid) > 0';
+ } else if ($this->blockingTasks === false) {
+ $parts[] = 'COUNT(blockingtask.phid) = 0';
+ }
+
+ if ($this->blockedTasks === true) {
+ $parts[] = 'COUNT(blockedtask.phid) > 0';
+ } else if ($this->blockedTasks === false) {
+ $parts[] = 'COUNT(blockedtask.phid) = 0';
+ }
+
+ return '('.implode(') OR (', $parts).')';
+ }
+
protected function getResultCursor($result) {
$id = $result->getID();

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 25, 11:42 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7576287
Default Alt Text
D15560.diff (4 KB)

Event Timeline