3 final class DrydockLogQuery
extends DrydockQuery
{
6 private $blueprintPHIDs;
7 private $resourcePHIDs;
9 private $operationPHIDs;
11 public function withIDs(array $ids) {
16 public function withBlueprintPHIDs(array $phids) {
17 $this->blueprintPHIDs
= $phids;
21 public function withResourcePHIDs(array $phids) {
22 $this->resourcePHIDs
= $phids;
26 public function withLeasePHIDs(array $phids) {
27 $this->leasePHIDs
= $phids;
31 public function withOperationPHIDs(array $phids) {
32 $this->operationPHIDs
= $phids;
36 public function newResultObject() {
37 return new DrydockLog();
40 protected function loadPage() {
41 return $this->loadStandardPage($this->newResultObject());
44 protected function didFilterPage(array $logs) {
45 $blueprint_phids = array_filter(mpull($logs, 'getBlueprintPHID'));
46 if ($blueprint_phids) {
47 $blueprints = id(new DrydockBlueprintQuery())
48 ->setParentQuery($this)
49 ->setViewer($this->getViewer())
50 ->withPHIDs($blueprint_phids)
52 $blueprints = mpull($blueprints, null, 'getPHID');
54 $blueprints = array();
57 foreach ($logs as $key => $log) {
59 $blueprint_phid = $log->getBlueprintPHID();
60 if ($blueprint_phid) {
61 $blueprint = idx($blueprints, $blueprint_phid);
63 $log->attachBlueprint($blueprint);
66 $resource_phids = array_filter(mpull($logs, 'getResourcePHID'));
67 if ($resource_phids) {
68 $resources = id(new DrydockResourceQuery())
69 ->setParentQuery($this)
70 ->setViewer($this->getViewer())
71 ->withPHIDs($resource_phids)
73 $resources = mpull($resources, null, 'getPHID');
78 foreach ($logs as $key => $log) {
80 $resource_phid = $log->getResourcePHID();
82 $resource = idx($resources, $resource_phid);
84 $log->attachResource($resource);
87 $lease_phids = array_filter(mpull($logs, 'getLeasePHID'));
89 $leases = id(new DrydockLeaseQuery())
90 ->setParentQuery($this)
91 ->setViewer($this->getViewer())
92 ->withPHIDs($lease_phids)
94 $leases = mpull($leases, null, 'getPHID');
99 foreach ($logs as $key => $log) {
101 $lease_phid = $log->getLeasePHID();
103 $lease = idx($leases, $lease_phid);
105 $log->attachLease($lease);
108 $operation_phids = array_filter(mpull($logs, 'getOperationPHID'));
109 if ($operation_phids) {
110 $operations = id(new DrydockRepositoryOperationQuery())
111 ->setParentQuery($this)
112 ->setViewer($this->getViewer())
113 ->withPHIDs($operation_phids)
115 $operations = mpull($operations, null, 'getPHID');
117 $operations = array();
120 foreach ($logs as $key => $log) {
122 $operation_phid = $log->getOperationPHID();
123 if ($operation_phid) {
124 $operation = idx($operations, $operation_phid);
126 $log->attachOperation($operation);
132 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
133 $where = parent
::buildWhereClauseParts($conn);
135 if ($this->ids
!== null) {
142 if ($this->blueprintPHIDs
!== null) {
145 'blueprintPHID IN (%Ls)',
146 $this->blueprintPHIDs
);
149 if ($this->resourcePHIDs
!== null) {
152 'resourcePHID IN (%Ls)',
153 $this->resourcePHIDs
);
156 if ($this->leasePHIDs
!== null) {
159 'leasePHID IN (%Ls)',
163 if ($this->operationPHIDs
!== null) {
166 'operationPHID IN (%Ls)',
167 $this->operationPHIDs
);