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 didFilterPage(array $logs) {
41 $blueprint_phids = array_filter(mpull($logs, 'getBlueprintPHID'));
42 if ($blueprint_phids) {
43 $blueprints = id(new DrydockBlueprintQuery())
44 ->setParentQuery($this)
45 ->setViewer($this->getViewer())
46 ->withPHIDs($blueprint_phids)
48 $blueprints = mpull($blueprints, null, 'getPHID');
50 $blueprints = array();
53 foreach ($logs as $key => $log) {
55 $blueprint_phid = $log->getBlueprintPHID();
56 if ($blueprint_phid) {
57 $blueprint = idx($blueprints, $blueprint_phid);
59 $log->attachBlueprint($blueprint);
62 $resource_phids = array_filter(mpull($logs, 'getResourcePHID'));
63 if ($resource_phids) {
64 $resources = id(new DrydockResourceQuery())
65 ->setParentQuery($this)
66 ->setViewer($this->getViewer())
67 ->withPHIDs($resource_phids)
69 $resources = mpull($resources, null, 'getPHID');
74 foreach ($logs as $key => $log) {
76 $resource_phid = $log->getResourcePHID();
78 $resource = idx($resources, $resource_phid);
80 $log->attachResource($resource);
83 $lease_phids = array_filter(mpull($logs, 'getLeasePHID'));
85 $leases = id(new DrydockLeaseQuery())
86 ->setParentQuery($this)
87 ->setViewer($this->getViewer())
88 ->withPHIDs($lease_phids)
90 $leases = mpull($leases, null, 'getPHID');
95 foreach ($logs as $key => $log) {
97 $lease_phid = $log->getLeasePHID();
99 $lease = idx($leases, $lease_phid);
101 $log->attachLease($lease);
104 $operation_phids = array_filter(mpull($logs, 'getOperationPHID'));
105 if ($operation_phids) {
106 $operations = id(new DrydockRepositoryOperationQuery())
107 ->setParentQuery($this)
108 ->setViewer($this->getViewer())
109 ->withPHIDs($operation_phids)
111 $operations = mpull($operations, null, 'getPHID');
113 $operations = array();
116 foreach ($logs as $key => $log) {
118 $operation_phid = $log->getOperationPHID();
119 if ($operation_phid) {
120 $operation = idx($operations, $operation_phid);
122 $log->attachOperation($operation);
128 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
129 $where = parent
::buildWhereClauseParts($conn);
131 if ($this->ids
!== null) {
138 if ($this->blueprintPHIDs
!== null) {
141 'blueprintPHID IN (%Ls)',
142 $this->blueprintPHIDs
);
145 if ($this->resourcePHIDs
!== null) {
148 'resourcePHID IN (%Ls)',
149 $this->resourcePHIDs
);
152 if ($this->leasePHIDs
!== null) {
155 'leasePHID IN (%Ls)',
159 if ($this->operationPHIDs
!== null) {
162 'operationPHID IN (%Ls)',
163 $this->operationPHIDs
);