Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/query/HarbormasterBuildTargetQuery.php
| <?php | <?php | ||||
| final class HarbormasterBuildTargetQuery | final class HarbormasterBuildTargetQuery | ||||
| extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
| private $ids; | private $ids; | ||||
| private $phids; | private $phids; | ||||
| private $buildPHIDs; | private $buildPHIDs; | ||||
| private $buildGenerations; | private $buildGenerations; | ||||
| private $dateCreatedMin; | |||||
| private $dateCreatedMax; | |||||
| private $dateStartedMin; | |||||
| private $dateStartedMax; | |||||
| private $dateCompletedMin; | |||||
| private $dateCompletedMax; | |||||
| private $statuses; | |||||
| private $needBuildSteps; | private $needBuildSteps; | ||||
| public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
| $this->ids = $ids; | $this->ids = $ids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
| $this->phids = $phids; | $this->phids = $phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withBuildPHIDs(array $build_phids) { | public function withBuildPHIDs(array $build_phids) { | ||||
| $this->buildPHIDs = $build_phids; | $this->buildPHIDs = $build_phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withBuildGenerations(array $build_generations) { | public function withBuildGenerations(array $build_generations) { | ||||
| $this->buildGenerations = $build_generations; | $this->buildGenerations = $build_generations; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDateCreatedBetween($min, $max) { | |||||
| $this->dateCreatedMin = $min; | |||||
| $this->dateCreatedMax = $max; | |||||
| return $this; | |||||
| } | |||||
| public function withDateStartedBetween($min, $max) { | |||||
| $this->dateStartedMin = $min; | |||||
| $this->dateStartedMax = $max; | |||||
| return $this; | |||||
| } | |||||
| public function withDateCompletedBetween($min, $max) { | |||||
| $this->dateCompletedMin = $min; | |||||
| $this->dateCompletedMax = $max; | |||||
| return $this; | |||||
| } | |||||
| public function withTargetStatuses(array $statuses) { | |||||
| $this->statuses = $statuses; | |||||
| return $this; | |||||
| } | |||||
| public function needBuildSteps($need_build_steps) { | public function needBuildSteps($need_build_steps) { | ||||
| $this->needBuildSteps = $need_build_steps; | $this->needBuildSteps = $need_build_steps; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function newResultObject() { | public function newResultObject() { | ||||
| return new HarbormasterBuildTarget(); | return new HarbormasterBuildTarget(); | ||||
| } | } | ||||
| Show All 28 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| if ($this->buildGenerations !== null) { | if ($this->buildGenerations !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'buildGeneration in (%Ld)', | 'buildGeneration in (%Ld)', | ||||
| $this->buildGenerations); | $this->buildGenerations); | ||||
| } | } | ||||
| if ($this->dateCreatedMin !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateCreated >= %d', | |||||
| $this->dateCreatedMin); | |||||
| } | |||||
| if ($this->dateCreatedMax !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateCreated <= %d', | |||||
| $this->dateCreatedMax); | |||||
| } | |||||
| if ($this->dateStartedMin !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateStarted >= %d', | |||||
| $this->dateStartedMin); | |||||
| } | |||||
| if ($this->dateStartedMax !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateStarted <= %d', | |||||
| $this->dateStartedMax); | |||||
| } | |||||
| if ($this->dateCompletedMin !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateCompleted >= %d', | |||||
| $this->dateCompletedMin); | |||||
| } | |||||
| if ($this->dateCompletedMax !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'dateCompleted <= %d', | |||||
| $this->dateCompletedMax); | |||||
| } | |||||
| if ($this->statuses !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'targetStatus IN (%Ls)', | |||||
| $this->statuses); | |||||
| } | |||||
| return $where; | return $where; | ||||
| } | } | ||||
| protected function didFilterPage(array $page) { | protected function didFilterPage(array $page) { | ||||
| if ($this->needBuildSteps) { | if ($this->needBuildSteps) { | ||||
| $step_phids = array(); | $step_phids = array(); | ||||
| foreach ($page as $target) { | foreach ($page as $target) { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||