Differential D21534 Diff 51255 src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
| <?php | <?php | ||||
| abstract class PhabricatorWorkerTaskQuery | abstract class PhabricatorWorkerTaskQuery | ||||
| extends PhabricatorQuery { | extends PhabricatorQuery { | ||||
| private $ids; | private $ids; | ||||
| private $dateModifiedSince; | private $dateModifiedSince; | ||||
| private $dateCreatedBefore; | private $dateCreatedBefore; | ||||
| private $objectPHIDs; | private $objectPHIDs; | ||||
| private $containerPHIDs; | |||||
| private $classNames; | private $classNames; | ||||
| private $limit; | private $limit; | ||||
| private $minFailureCount; | private $minFailureCount; | ||||
| private $maxFailureCount; | private $maxFailureCount; | ||||
| private $minPriority; | |||||
| private $maxPriority; | |||||
| public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
| $this->ids = $ids; | $this->ids = $ids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDateModifiedSince($timestamp) { | public function withDateModifiedSince($timestamp) { | ||||
| $this->dateModifiedSince = $timestamp; | $this->dateModifiedSince = $timestamp; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDateCreatedBefore($timestamp) { | public function withDateCreatedBefore($timestamp) { | ||||
| $this->dateCreatedBefore = $timestamp; | $this->dateCreatedBefore = $timestamp; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withObjectPHIDs(array $phids) { | public function withObjectPHIDs(array $phids) { | ||||
| $this->objectPHIDs = $phids; | $this->objectPHIDs = $phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withContainerPHIDs(array $phids) { | |||||
| $this->containerPHIDs = $phids; | |||||
| return $this; | |||||
| } | |||||
| public function withClassNames(array $names) { | public function withClassNames(array $names) { | ||||
| $this->classNames = $names; | $this->classNames = $names; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withFailureCountBetween($min, $max) { | public function withFailureCountBetween($min, $max) { | ||||
| $this->minFailureCount = $min; | $this->minFailureCount = $min; | ||||
| $this->maxFailureCount = $max; | $this->maxFailureCount = $max; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withPriorityBetween($min, $max) { | |||||
| $this->minPriority = $min; | |||||
| $this->maxPriority = $max; | |||||
| return $this; | |||||
| } | |||||
| public function setLimit($limit) { | public function setLimit($limit) { | ||||
| $this->limit = $limit; | $this->limit = $limit; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function buildWhereClause(AphrontDatabaseConnection $conn) { | protected function buildWhereClause(AphrontDatabaseConnection $conn) { | ||||
| $where = array(); | $where = array(); | ||||
| if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'id in (%Ld)', | 'id in (%Ld)', | ||||
| $this->ids); | $this->ids); | ||||
| } | } | ||||
| if ($this->objectPHIDs !== null) { | if ($this->objectPHIDs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'objectPHID IN (%Ls)', | 'objectPHID IN (%Ls)', | ||||
| $this->objectPHIDs); | $this->objectPHIDs); | ||||
| } | } | ||||
| if ($this->containerPHIDs !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'containerPHID IN (%Ls)', | |||||
| $this->containerPHIDs); | |||||
| } | |||||
| if ($this->dateModifiedSince !== null) { | if ($this->dateModifiedSince !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'dateModified > %d', | 'dateModified > %d', | ||||
| $this->dateModifiedSince); | $this->dateModifiedSince); | ||||
| } | } | ||||
| if ($this->dateCreatedBefore !== null) { | if ($this->dateCreatedBefore !== null) { | ||||
| Show All 19 Lines | protected function buildWhereClause(AphrontDatabaseConnection $conn) { | ||||
| if ($this->maxFailureCount !== null) { | if ($this->maxFailureCount !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'failureCount <= %d', | 'failureCount <= %d', | ||||
| $this->maxFailureCount); | $this->maxFailureCount); | ||||
| } | } | ||||
| if ($this->minPriority !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'priority >= %d', | |||||
| $this->minPriority); | |||||
| } | |||||
| if ($this->maxPriority !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'priority <= %d', | |||||
| $this->maxPriority); | |||||
| } | |||||
| return $this->formatWhereClause($conn, $where); | return $this->formatWhereClause($conn, $where); | ||||
| } | } | ||||
| protected function buildOrderClause(AphrontDatabaseConnection $conn) { | protected function buildOrderClause(AphrontDatabaseConnection $conn) { | ||||
| // NOTE: The garbage collector executes this query with a date constraint, | // NOTE: The garbage collector executes this query with a date constraint, | ||||
| // and the query is inefficient if we don't use the same key for ordering. | // and the query is inefficient if we don't use the same key for ordering. | ||||
| // See T9808 for discussion. | // See T9808 for discussion. | ||||
| Show All 18 Lines | |||||