Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/query/DrydockLogQuery.php
<?php | <?php | ||||
final class DrydockLogQuery extends DrydockQuery { | final class DrydockLogQuery extends DrydockQuery { | ||||
private $blueprintPHIDs; | private $blueprintPHIDs; | ||||
private $resourcePHIDs; | private $resourcePHIDs; | ||||
private $leasePHIDs; | private $leasePHIDs; | ||||
private $operationPHIDs; | |||||
public function withBlueprintPHIDs(array $phids) { | public function withBlueprintPHIDs(array $phids) { | ||||
$this->blueprintPHIDs = $phids; | $this->blueprintPHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withResourcePHIDs(array $phids) { | public function withResourcePHIDs(array $phids) { | ||||
$this->resourcePHIDs = $phids; | $this->resourcePHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withLeasePHIDs(array $phids) { | public function withLeasePHIDs(array $phids) { | ||||
$this->leasePHIDs = $phids; | $this->leasePHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withOperationPHIDs(array $phids) { | |||||
$this->operationPHIDs = $phids; | |||||
return $this; | |||||
} | |||||
public function newResultObject() { | public function newResultObject() { | ||||
return new DrydockLog(); | return new DrydockLog(); | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | return $this->loadStandardPage($this->newResultObject()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | foreach ($logs as $key => $log) { | ||||
$lease = null; | $lease = null; | ||||
$lease_phid = $log->getLeasePHID(); | $lease_phid = $log->getLeasePHID(); | ||||
if ($lease_phid) { | if ($lease_phid) { | ||||
$lease = idx($leases, $lease_phid); | $lease = idx($leases, $lease_phid); | ||||
} | } | ||||
$log->attachLease($lease); | $log->attachLease($lease); | ||||
} | } | ||||
$operation_phids = array_filter(mpull($logs, 'getOperationPHID')); | |||||
if ($operation_phids) { | |||||
$operations = id(new DrydockRepositoryOperationQuery()) | |||||
->setParentQuery($this) | |||||
->setViewer($this->getViewer()) | |||||
->withPHIDs($operation_phids) | |||||
->execute(); | |||||
$operations = mpull($operations, null, 'getPHID'); | |||||
} else { | |||||
$operations = array(); | |||||
} | |||||
foreach ($logs as $key => $log) { | |||||
$operation = null; | |||||
$operation_phid = $log->getOperationPHID(); | |||||
if ($operation_phid) { | |||||
$operation = idx($operations, $operation_phid); | |||||
} | |||||
$log->attachOperation($operation); | |||||
} | |||||
return $logs; | return $logs; | ||||
} | } | ||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = parent::buildWhereClauseParts($conn); | $where = parent::buildWhereClauseParts($conn); | ||||
if ($this->blueprintPHIDs !== null) { | if ($this->blueprintPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
Show All 11 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->leasePHIDs !== null) { | if ($this->leasePHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'leasePHID IN (%Ls)', | 'leasePHID IN (%Ls)', | ||||
$this->leasePHIDs); | $this->leasePHIDs); | ||||
} | } | ||||
if ($this->operationPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'operationPHID IN (%Ls)', | |||||
$this->operationPHIDs); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
} | } |