Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/query/DifferentialRevisionQuery.php
| <?php | <?php | ||||
| /** | /** | ||||
| * @task config Query Configuration | * @task config Query Configuration | ||||
| * @task exec Query Execution | * @task exec Query Execution | ||||
| * @task internal Internals | * @task internal Internals | ||||
| */ | */ | ||||
| final class DifferentialRevisionQuery | final class DifferentialRevisionQuery | ||||
| extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
| private $pathIDs = array(); | private $pathIDs = array(); | ||||
| private $status = 'status-any'; | |||||
| private $authors = array(); | private $authors = array(); | ||||
| private $draftAuthors = array(); | private $draftAuthors = array(); | ||||
| private $ccs = array(); | private $ccs = array(); | ||||
| private $reviewers = array(); | private $reviewers = array(); | ||||
| private $revIDs = array(); | private $revIDs = array(); | ||||
| private $commitHashes = array(); | private $commitHashes = array(); | ||||
| private $commitPHIDs = array(); | private $commitPHIDs = array(); | ||||
| private $phids = array(); | private $phids = array(); | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | /* -( Query Configuration )------------------------------------------------ */ | ||||
| * @return this | * @return this | ||||
| * @task config | * @task config | ||||
| */ | */ | ||||
| public function withCommitPHIDs(array $commit_phids) { | public function withCommitPHIDs(array $commit_phids) { | ||||
| $this->commitPHIDs = $commit_phids; | $this->commitPHIDs = $commit_phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | |||||
| * Filter results to revisions with a given status. Provide a class constant, | |||||
| * such as `DifferentialLegacyQuery::STATUS_OPEN`. | |||||
| * | |||||
| * @param const Class STATUS constant, like STATUS_OPEN. | |||||
| * @return this | |||||
| * @task config | |||||
| */ | |||||
| public function withStatus($status_constant) { | |||||
| $this->status = $status_constant; | |||||
| return $this; | |||||
| } | |||||
| public function withStatuses(array $statuses) { | public function withStatuses(array $statuses) { | ||||
| $this->statuses = $statuses; | $this->statuses = $statuses; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withIsOpen($is_open) { | public function withIsOpen($is_open) { | ||||
| $this->isOpen = $is_open; | $this->isOpen = $is_open; | ||||
| return $this; | return $this; | ||||
| ▲ Show 20 Lines • Show All 542 Lines • ▼ Show 20 Lines | protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
| if ($this->updatedEpochMax !== null) { | if ($this->updatedEpochMax !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'r.dateModified <= %d', | 'r.dateModified <= %d', | ||||
| $this->updatedEpochMax); | $this->updatedEpochMax); | ||||
| } | } | ||||
| // NOTE: Although the status constants are integers in PHP, the column is a | |||||
| // string column in MySQL, and MySQL won't use keys on string columns if | |||||
| // you put integers in the query. | |||||
| $statuses = DifferentialLegacyQuery::getQueryValues($this->status); | |||||
| if ($statuses !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn_r, | |||||
| 'r.status IN (%Ls)', | |||||
| $statuses); | |||||
| } | |||||
| if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'r.status in (%Ls)', | 'r.status in (%Ls)', | ||||
| DifferentialLegacyQuery::getLegacyValues($this->statuses)); | DifferentialLegacyQuery::getLegacyValues($this->statuses)); | ||||
| } | } | ||||
| if ($this->isOpen !== null) { | if ($this->isOpen !== null) { | ||||
| if ($this->isOpen) { | if ($this->isOpen) { | ||||
| $statuses = DifferentialLegacyQuery::getQueryValues( | $statuses = DifferentialLegacyQuery::getModernValues( | ||||
| DifferentialLegacyQuery::STATUS_OPEN); | DifferentialLegacyQuery::STATUS_OPEN); | ||||
| } else { | } else { | ||||
| $statuses = DifferentialLegacyQuery::getQueryValues( | $statuses = DifferentialLegacyQuery::getModernValues( | ||||
| DifferentialLegacyQuery::STATUS_CLOSED); | DifferentialLegacyQuery::STATUS_CLOSED); | ||||
| } | } | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'r.status in (%Ls)', | 'r.status in (%Ls)', | ||||
| $statuses); | DifferentialLegacyQuery::getLegacyValues($statuses)); | ||||
| } | } | ||||
| $where[] = $this->buildWhereClauseParts($conn_r); | $where[] = $this->buildWhereClauseParts($conn_r); | ||||
| return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
| } | } | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines | |||||