Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/autopatches/20180914.drydock.01.operationphid.sql b/resources/sql/autopatches/20180914.drydock.01.operationphid.sql
new file mode 100644
index 0000000000..bdfe02b0df
--- /dev/null
+++ b/resources/sql/autopatches/20180914.drydock.01.operationphid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_drydock.drydock_log
+ ADD operationPHID VARBINARY(64);
diff --git a/src/applications/drydock/query/DrydockLogQuery.php b/src/applications/drydock/query/DrydockLogQuery.php
index 00980edb4d..b73ad371ae 100644
--- a/src/applications/drydock/query/DrydockLogQuery.php
+++ b/src/applications/drydock/query/DrydockLogQuery.php
@@ -1,126 +1,160 @@
<?php
final class DrydockLogQuery extends DrydockQuery {
private $blueprintPHIDs;
private $resourcePHIDs;
private $leasePHIDs;
+ private $operationPHIDs;
public function withBlueprintPHIDs(array $phids) {
$this->blueprintPHIDs = $phids;
return $this;
}
public function withResourcePHIDs(array $phids) {
$this->resourcePHIDs = $phids;
return $this;
}
public function withLeasePHIDs(array $phids) {
$this->leasePHIDs = $phids;
return $this;
}
+ public function withOperationPHIDs(array $phids) {
+ $this->operationPHIDs = $phids;
+ return $this;
+ }
+
public function newResultObject() {
return new DrydockLog();
}
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
protected function didFilterPage(array $logs) {
$blueprint_phids = array_filter(mpull($logs, 'getBlueprintPHID'));
if ($blueprint_phids) {
$blueprints = id(new DrydockBlueprintQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
->withPHIDs($blueprint_phids)
->execute();
$blueprints = mpull($blueprints, null, 'getPHID');
} else {
$blueprints = array();
}
foreach ($logs as $key => $log) {
$blueprint = null;
$blueprint_phid = $log->getBlueprintPHID();
if ($blueprint_phid) {
$blueprint = idx($blueprints, $blueprint_phid);
}
$log->attachBlueprint($blueprint);
}
$resource_phids = array_filter(mpull($logs, 'getResourcePHID'));
if ($resource_phids) {
$resources = id(new DrydockResourceQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
->withPHIDs($resource_phids)
->execute();
$resources = mpull($resources, null, 'getPHID');
} else {
$resources = array();
}
foreach ($logs as $key => $log) {
$resource = null;
$resource_phid = $log->getResourcePHID();
if ($resource_phid) {
$resource = idx($resources, $resource_phid);
}
$log->attachResource($resource);
}
$lease_phids = array_filter(mpull($logs, 'getLeasePHID'));
if ($lease_phids) {
$leases = id(new DrydockLeaseQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
->withPHIDs($lease_phids)
->execute();
$leases = mpull($leases, null, 'getPHID');
} else {
$leases = array();
}
foreach ($logs as $key => $log) {
$lease = null;
$lease_phid = $log->getLeasePHID();
if ($lease_phid) {
$lease = idx($leases, $lease_phid);
}
$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;
}
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->blueprintPHIDs !== null) {
$where[] = qsprintf(
$conn,
'blueprintPHID IN (%Ls)',
$this->blueprintPHIDs);
}
if ($this->resourcePHIDs !== null) {
$where[] = qsprintf(
$conn,
'resourcePHID IN (%Ls)',
$this->resourcePHIDs);
}
if ($this->leasePHIDs !== null) {
$where[] = qsprintf(
$conn,
'leasePHID IN (%Ls)',
$this->leasePHIDs);
}
+ if ($this->operationPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'operationPHID IN (%Ls)',
+ $this->operationPHIDs);
+ }
+
return $where;
}
}
diff --git a/src/applications/drydock/storage/DrydockLog.php b/src/applications/drydock/storage/DrydockLog.php
index 5d75d82c65..81879944a0 100644
--- a/src/applications/drydock/storage/DrydockLog.php
+++ b/src/applications/drydock/storage/DrydockLog.php
@@ -1,115 +1,135 @@
<?php
final class DrydockLog extends DrydockDAO
implements PhabricatorPolicyInterface {
protected $blueprintPHID;
protected $resourcePHID;
protected $leasePHID;
+ protected $operationPHID;
protected $epoch;
protected $type;
protected $data = array();
private $blueprint = self::ATTACHABLE;
private $resource = self::ATTACHABLE;
private $lease = self::ATTACHABLE;
+ private $operation = self::ATTACHABLE;
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_SERIALIZATION => array(
'data' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'blueprintPHID' => 'phid?',
'resourcePHID' => 'phid?',
'leasePHID' => 'phid?',
+ 'operationPHID' => 'phid?',
'type' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_blueprint' => array(
'columns' => array('blueprintPHID', 'type'),
),
'key_resource' => array(
'columns' => array('resourcePHID', 'type'),
),
'key_lease' => array(
'columns' => array('leasePHID', 'type'),
),
+ 'key_operation' => array(
+ 'columns' => array('operationPHID', 'type'),
+ ),
'epoch' => array(
'columns' => array('epoch'),
),
),
) + parent::getConfiguration();
}
public function attachBlueprint(DrydockBlueprint $blueprint = null) {
$this->blueprint = $blueprint;
return $this;
}
public function getBlueprint() {
return $this->assertAttached($this->blueprint);
}
public function attachResource(DrydockResource $resource = null) {
$this->resource = $resource;
return $this;
}
public function getResource() {
return $this->assertAttached($this->resource);
}
public function attachLease(DrydockLease $lease = null) {
$this->lease = $lease;
return $this;
}
public function getLease() {
return $this->assertAttached($this->lease);
}
+ public function attachOperation(
+ DrydockRepositoryOperation $operation = null) {
+ $this->operation = $operation;
+ return $this;
+ }
+
+ public function getOperation() {
+ return $this->assertAttached($this->operation);
+ }
+
public function isComplete() {
if ($this->getBlueprintPHID() && !$this->getBlueprint()) {
return false;
}
if ($this->getResourcePHID() && !$this->getResource()) {
return false;
}
if ($this->getLeasePHID() && !$this->getLease()) {
return false;
}
+ if ($this->getOperationPHID() && !$this->getOperation()) {
+ return false;
+ }
+
return true;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
// NOTE: We let you see that logs exist no matter what, but don't actually
// show you log content unless you can see all of the associated objects.
return PhabricatorPolicies::getMostOpenPolicy();
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
public function describeAutomaticCapability($capability) {
return pht(
- 'To view log details, you must be able to view the associated '.
- 'blueprint, resource and lease.');
+ 'To view log details, you must be able to view all associated '.
+ 'blueprints, resources, leases, and repository operations.');
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Aug 15, 1:58 PM (6 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
190963
Default Alt Text
(8 KB)

Event Timeline