Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/query/ManiphestTaskQuery.php
| Show All 14 Lines | final class ManiphestTaskQuery | ||||
| private $ownerPHIDs = array(); | private $ownerPHIDs = array(); | ||||
| private $includeUnowned = null; | private $includeUnowned = null; | ||||
| private $projectPHIDs = array(); | private $projectPHIDs = array(); | ||||
| private $xprojectPHIDs = array(); | private $xprojectPHIDs = array(); | ||||
| private $subscriberPHIDs = array(); | private $subscriberPHIDs = array(); | ||||
| private $anyProjectPHIDs = array(); | private $anyProjectPHIDs = array(); | ||||
| private $anyUserProjectPHIDs = array(); | private $anyUserProjectPHIDs = array(); | ||||
| private $includeNoProject = null; | private $includeNoProject = null; | ||||
| private $allColumnPHIDs = array(); | |||||
| private $anyColumnPHIDs = array(); | |||||
| private $dateCreatedAfter; | private $dateCreatedAfter; | ||||
| private $dateCreatedBefore; | private $dateCreatedBefore; | ||||
| private $dateModifiedAfter; | private $dateModifiedAfter; | ||||
| private $dateModifiedBefore; | private $dateModifiedBefore; | ||||
| private $fullTextSearch = ''; | private $fullTextSearch = ''; | ||||
| private $status = 'status-any'; | private $status = 'status-any'; | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | public function setOrderBy($order) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withAnyProjects(array $projects) { | public function withAnyProjects(array $projects) { | ||||
| $this->anyProjectPHIDs = $projects; | $this->anyProjectPHIDs = $projects; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withAllColumns(array $columns) { | |||||
| $this->allColumnPHIDs = $columns; | |||||
| return $this; | |||||
| } | |||||
| public function withAnyColumns(array $columns) { | |||||
| $this->anyColumnPHIDs = $columns; | |||||
| return $this; | |||||
| } | |||||
| public function withAnyUserProjects(array $users) { | public function withAnyUserProjects(array $users) { | ||||
| $this->anyUserProjectPHIDs = $users; | $this->anyUserProjectPHIDs = $users; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDateCreatedBefore($date_created_before) { | public function withDateCreatedBefore($date_created_before) { | ||||
| $this->dateCreatedBefore = $date_created_before; | $this->dateCreatedBefore = $date_created_before; | ||||
| return $this; | return $this; | ||||
| Show All 32 Lines | public function loadPage() { | ||||
| $where[] = $this->buildStatusesWhereClause($conn); | $where[] = $this->buildStatusesWhereClause($conn); | ||||
| $where[] = $this->buildPrioritiesWhereClause($conn); | $where[] = $this->buildPrioritiesWhereClause($conn); | ||||
| $where[] = $this->buildAuthorWhereClause($conn); | $where[] = $this->buildAuthorWhereClause($conn); | ||||
| $where[] = $this->buildOwnerWhereClause($conn); | $where[] = $this->buildOwnerWhereClause($conn); | ||||
| $where[] = $this->buildSubscriberWhereClause($conn); | $where[] = $this->buildSubscriberWhereClause($conn); | ||||
| $where[] = $this->buildProjectWhereClause($conn); | $where[] = $this->buildProjectWhereClause($conn); | ||||
| $where[] = $this->buildAnyProjectWhereClause($conn); | $where[] = $this->buildAnyProjectWhereClause($conn); | ||||
| $where[] = $this->buildAnyUserProjectWhereClause($conn); | $where[] = $this->buildAnyUserProjectWhereClause($conn); | ||||
| $where[] = $this->buildColumnWhereClause($conn); | |||||
| $where[] = $this->buildAnyColumnWhereClause($conn); | |||||
| $where[] = $this->buildXProjectWhereClause($conn); | $where[] = $this->buildXProjectWhereClause($conn); | ||||
| $where[] = $this->buildFullTextWhereClause($conn); | $where[] = $this->buildFullTextWhereClause($conn); | ||||
| if ($this->dateCreatedAfter) { | if ($this->dateCreatedAfter) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'dateCreated >= %d', | 'dateCreated >= %d', | ||||
| $this->dateCreatedAfter); | $this->dateCreatedAfter); | ||||
| ▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | private function buildAnyProjectWhereClause(AphrontDatabaseConnection $conn) { | ||||
| } | } | ||||
| return qsprintf( | return qsprintf( | ||||
| $conn, | $conn, | ||||
| 'anyproject.projectPHID IN (%Ls)', | 'anyproject.projectPHID IN (%Ls)', | ||||
| $this->anyProjectPHIDs); | $this->anyProjectPHIDs); | ||||
| } | } | ||||
| private function buildColumnWhereClause(AphrontDatabaseConnection $conn) { | |||||
| if (!$this->allColumnPHIDs) { | |||||
| return null; | |||||
| } | |||||
| $parts[] = qsprintf( | |||||
| $conn, | |||||
| 'boardcolumn.dst in (%Ls)', | |||||
| $this->allColumnPHIDs); | |||||
bluehawk: This doesn't work, and I have no idea how to ask for if an edge exists in the… | |||||
| return '('.implode(') AND (', $parts).')'; | |||||
| } | |||||
| private function buildAnyColumnWhereClause(AphrontDatabaseConnection $conn) { | |||||
| if (!$this->anyColumnPHIDs) { | |||||
| return null; | |||||
| } | |||||
Not Done Inline ActionsAnd this is just copy paste fail. bluehawk: And this is just copy paste fail. | |||||
| return qsprintf( | |||||
| $conn, | |||||
| 'boardcolumn.dst IN (%Ls)', | |||||
| $this->anyColumnPHIDs); | |||||
| } | |||||
| private function buildAnyUserProjectWhereClause( | private function buildAnyUserProjectWhereClause( | ||||
| AphrontDatabaseConnection $conn) { | AphrontDatabaseConnection $conn) { | ||||
| if (!$this->anyUserProjectPHIDs) { | if (!$this->anyUserProjectPHIDs) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| $projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
| ->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | private function buildCustomOrderClause(AphrontDatabaseConnection $conn) { | ||||
| return 'ORDER BY '.implode(', ', $order); | return 'ORDER BY '.implode(', ', $order); | ||||
| } | } | ||||
| private function buildJoinsClause(AphrontDatabaseConnection $conn_r) { | private function buildJoinsClause(AphrontDatabaseConnection $conn_r) { | ||||
| $project_dao = new ManiphestTaskProject(); | $project_dao = new ManiphestTaskProject(); | ||||
| $joins = array(); | $joins = array(); | ||||
Not Done Inline ActionsAdd a JOIN to the edge table here, e.g. JOIN edge column ON edge.src = task.phid AND edge.type = 43 epriestley: Add a JOIN to the edge table here, e.g. `JOIN edge column ON edge.src = task.phid AND edge.type… | |||||
| if ($this->projectPHIDs || $this->includeNoProject) { | if ($this->projectPHIDs || $this->includeNoProject) { | ||||
| $joins[] = qsprintf( | $joins[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| '%Q JOIN %T project ON project.taskPHID = task.phid', | '%Q JOIN %T project ON project.taskPHID = task.phid', | ||||
| ($this->includeNoProject ? 'LEFT' : ''), | ($this->includeNoProject ? 'LEFT' : ''), | ||||
| $project_dao->getTableName()); | $project_dao->getTableName()); | ||||
| } | } | ||||
| if ($this->anyProjectPHIDs || $this->anyUserProjectPHIDs) { | if ($this->anyProjectPHIDs || $this->anyUserProjectPHIDs) { | ||||
| $joins[] = qsprintf( | $joins[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'JOIN %T anyproject ON anyproject.taskPHID = task.phid', | 'JOIN %T anyproject ON anyproject.taskPHID = task.phid', | ||||
| $project_dao->getTableName()); | $project_dao->getTableName()); | ||||
| } | } | ||||
| if ($this->allColumnPHIDs || $this->anyColumnPHIDs) { | |||||
| $joins[] = qsprintf( | |||||
| $conn_r, | |||||
| 'JOIN edge boardcolumn ON boardcolumn.src = task.phid | |||||
| AND boardcolumn.type = %d', | |||||
| PhabricatorEdgeConfig::TYPE_OBJECT_HAS_COLUMN | |||||
| ); | |||||
| } | |||||
| if ($this->xprojectPHIDs) { | if ($this->xprojectPHIDs) { | ||||
| $joins[] = qsprintf( | $joins[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'LEFT JOIN %T xproject ON xproject.taskPHID = task.phid | 'LEFT JOIN %T xproject ON xproject.taskPHID = task.phid | ||||
| AND xproject.projectPHID IN (%Ls)', | AND xproject.projectPHID IN (%Ls)', | ||||
| $project_dao->getTableName(), | $project_dao->getTableName(), | ||||
| $this->xprojectPHIDs); | $this->xprojectPHIDs); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines | |||||
This doesn't work, and I have no idea how to ask for if an edge exists in the phabricator_maniphest.edge table with a type of 43 and references this task.