Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/query/ManiphestTaskQuery.php
Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
$task_dao = new ManiphestTask(); | $task_dao = new ManiphestTask(); | ||||
$conn = $task_dao->establishConnection('r'); | $conn = $task_dao->establishConnection('r'); | ||||
$where = $this->buildWhereClause($conn); | $where = $this->buildWhereClause($conn); | ||||
$group_column = ''; | $group_column = qsprintf($conn, ''); | ||||
switch ($this->groupBy) { | switch ($this->groupBy) { | ||||
case self::GROUP_PROJECT: | case self::GROUP_PROJECT: | ||||
$group_column = qsprintf( | $group_column = qsprintf( | ||||
$conn, | $conn, | ||||
', projectGroupName.indexedObjectPHID projectGroupPHID'); | ', projectGroupName.indexedObjectPHID projectGroupPHID'); | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | private function buildOwnerWhereClause(AphrontDatabaseConnection $conn) { | ||||
if ($this->ownerPHIDs !== null) { | if ($this->ownerPHIDs !== null) { | ||||
$subclause[] = qsprintf( | $subclause[] = qsprintf( | ||||
$conn, | $conn, | ||||
'task.ownerPHID IN (%Ls)', | 'task.ownerPHID IN (%Ls)', | ||||
$this->ownerPHIDs); | $this->ownerPHIDs); | ||||
} | } | ||||
if (!$subclause) { | if (!$subclause) { | ||||
return ''; | return qsprintf($conn, ''); | ||||
} | } | ||||
return '('.implode(') OR (', $subclause).')'; | return qsprintf($conn, '%LO', $subclause); | ||||
} | } | ||||
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | ||||
$open_statuses = ManiphestTaskStatus::getOpenStatusConstants(); | $open_statuses = ManiphestTaskStatus::getOpenStatusConstants(); | ||||
$edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; | $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; | ||||
$task_table = $this->newResultObject()->getTableName(); | $task_table = $this->newResultObject()->getTableName(); | ||||
$parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; | $parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | if ($this->subtaskIDs !== null) { | ||||
$this->subtaskIDs); | $this->subtaskIDs); | ||||
} | } | ||||
$joins[] = parent::buildJoinClauseParts($conn); | $joins[] = parent::buildJoinClauseParts($conn); | ||||
return $joins; | return $joins; | ||||
} | } | ||||
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) { | protected function buildGroupClause(AphrontDatabaseConnection $conn) { | ||||
$joined_multiple_rows = | $joined_multiple_rows = | ||||
($this->hasOpenParents !== null) || | ($this->hasOpenParents !== null) || | ||||
($this->hasOpenSubtasks !== null) || | ($this->hasOpenSubtasks !== null) || | ||||
($this->parentTaskIDs !== null) || | ($this->parentTaskIDs !== null) || | ||||
($this->subtaskIDs !== null) || | ($this->subtaskIDs !== null) || | ||||
$this->shouldGroupQueryResultRows(); | $this->shouldGroupQueryResultRows(); | ||||
$joined_project_name = ($this->groupBy == self::GROUP_PROJECT); | $joined_project_name = ($this->groupBy == self::GROUP_PROJECT); | ||||
// If we're joining multiple rows, we need to group the results by the | // If we're joining multiple rows, we need to group the results by the | ||||
// task IDs. | // task IDs. | ||||
if ($joined_multiple_rows) { | if ($joined_multiple_rows) { | ||||
if ($joined_project_name) { | if ($joined_project_name) { | ||||
return 'GROUP BY task.phid, projectGroup.dst'; | return qsprintf($conn, 'GROUP BY task.phid, projectGroup.dst'); | ||||
} else { | } else { | ||||
return 'GROUP BY task.phid'; | return qsprintf($conn, 'GROUP BY task.phid'); | ||||
} | } | ||||
} else { | |||||
return ''; | |||||
} | } | ||||
return qsprintf($conn, ''); | |||||
} | } | ||||
protected function buildHavingClauseParts(AphrontDatabaseConnection $conn) { | protected function buildHavingClauseParts(AphrontDatabaseConnection $conn) { | ||||
$having = parent::buildHavingClauseParts($conn); | $having = parent::buildHavingClauseParts($conn); | ||||
if ($this->hasOpenParents !== null) { | if ($this->hasOpenParents !== null) { | ||||
if (!$this->hasOpenParents) { | if (!$this->hasOpenParents) { | ||||
▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines |