Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/query/HarbormasterBuildQuery.php
<?php | <?php | ||||
final class HarbormasterBuildQuery | final class HarbormasterBuildQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $buildStatuses; | private $buildStatuses; | ||||
private $buildablePHIDs; | private $buildablePHIDs; | ||||
private $buildPlanPHIDs; | private $buildPlanPHIDs; | ||||
private $needBuildPlans; | |||||
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; | ||||
Show All 9 Lines | public function withBuildablePHIDs(array $buildable_phids) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withBuildPlanPHIDs(array $build_plan_phids) { | public function withBuildPlanPHIDs(array $build_plan_phids) { | ||||
$this->buildPlanPHIDs = $build_plan_phids; | $this->buildPlanPHIDs = $build_plan_phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needBuildPlans($need_plans) { | |||||
$this->needBuildPlans = $need_plans; | |||||
return $this; | |||||
} | |||||
protected function loadPage() { | protected function loadPage() { | ||||
$table = new HarbormasterBuild(); | $table = new HarbormasterBuild(); | ||||
$conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
$data = queryfx_all( | $data = queryfx_all( | ||||
$conn_r, | $conn_r, | ||||
'SELECT * FROM %T %Q %Q %Q', | 'SELECT * FROM %T %Q %Q %Q', | ||||
$table->getTableName(), | $table->getTableName(), | ||||
Show All 25 Lines | foreach ($page as $key => $build) { | ||||
} | } | ||||
$build->attachBuildable($buildables[$buildable_phid]); | $build->attachBuildable($buildables[$buildable_phid]); | ||||
} | } | ||||
return $page; | return $page; | ||||
} | } | ||||
protected function didFilterPage(array $page) { | protected function didFilterPage(array $page) { | ||||
if ($this->needBuildPlans) { | |||||
$plans = array(); | $plans = array(); | ||||
$plan_phids = array_filter(mpull($page, 'getBuildPlanPHID')); | $plan_phids = array_filter(mpull($page, 'getBuildPlanPHID')); | ||||
if ($plan_phids) { | if ($plan_phids) { | ||||
$plans = id(new PhabricatorObjectQuery()) | $plans = id(new PhabricatorObjectQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($plan_phids) | ->withPHIDs($plan_phids) | ||||
->setParentQuery($this) | ->setParentQuery($this) | ||||
->execute(); | ->execute(); | ||||
$plans = mpull($plans, null, 'getPHID'); | $plans = mpull($plans, null, 'getPHID'); | ||||
} | } | ||||
foreach ($page as $key => $build) { | foreach ($page as $key => $build) { | ||||
$plan_phid = $build->getBuildPlanPHID(); | $plan_phid = $build->getBuildPlanPHID(); | ||||
$build->attachBuildPlan(idx($plans, $plan_phid)); | $build->attachBuildPlan(idx($plans, $plan_phid)); | ||||
} | } | ||||
} | |||||
return $page; | return $page; | ||||
} | } | ||||
private function buildWhereClause(AphrontDatabaseConnection $conn_r) { | private function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
$where = array(); | $where = array(); | ||||
if ($this->ids) { | if ($this->ids) { | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |