Page MenuHomePhabricator

D15354.diff
No OneTemporary

D15354.diff

diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
@@ -9,8 +9,6 @@
$buildable = id(new HarbormasterBuildableQuery())
->setViewer($viewer)
->withIDs(array($request->getURIData('id')))
- ->needBuildableHandles(true)
- ->needContainerHandles(true)
->executeOne();
if (!$buildable) {
return new Aphront404Response();
@@ -167,15 +165,18 @@
->setActionList($actions);
$box->addPropertyList($properties);
- if ($buildable->getContainerHandle() !== null) {
+ $container_phid = $buildable->getContainerPHID();
+ $buildable_phid = $buildable->getBuildablePHID();
+
+ if ($container_phid) {
$properties->addProperty(
pht('Container'),
- $buildable->getContainerHandle()->renderLink());
+ $viewer->renderHandle($container_phid));
}
$properties->addProperty(
pht('Buildable'),
- $buildable->getBuildableHandle()->renderLink());
+ $viewer->renderHandle($buildable_phid));
$properties->addProperty(
pht('Origin'),
diff --git a/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php b/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
--- a/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
+++ b/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
@@ -6,7 +6,6 @@
public function getHarbormasterContainerPHID();
public function getBuildVariables();
-
public function getAvailableBuildVariables();
}
diff --git a/src/applications/harbormaster/phid/HarbormasterBuildablePHIDType.php b/src/applications/harbormaster/phid/HarbormasterBuildablePHIDType.php
--- a/src/applications/harbormaster/phid/HarbormasterBuildablePHIDType.php
+++ b/src/applications/harbormaster/phid/HarbormasterBuildablePHIDType.php
@@ -21,8 +21,7 @@
array $phids) {
return id(new HarbormasterBuildableQuery())
- ->withPHIDs($phids)
- ->needBuildableHandles(true);
+ ->withPHIDs($phids);
}
public function loadHandles(
@@ -30,15 +29,30 @@
array $handles,
array $objects) {
+ $viewer = $this->getViewer();
+
+ $target_phids = array();
+ foreach ($objects as $phid => $object) {
+ $target_phids[] = $object->getBuildablePHID();
+ }
+ $target_handles = $viewer->loadHandles($target_phids);
+
foreach ($handles as $phid => $handle) {
$buildable = $objects[$phid];
$id = $buildable->getID();
- $target = $buildable->getBuildableHandle()->getFullName();
+ $buildable_phid = $buildable->getBuildablePHID();
+
+ $target = $target_handles[$buildable_phid];
+ $target_name = $target->getFullName();
+
+ $uri = $buildable->getURI();
+ $monogram = $buildable->getMonogram();
- $handle->setURI("/B{$id}");
- $handle->setName("B{$id}");
- $handle->setFullName("B{$id}: ".$target);
+ $handle
+ ->setURI($uri)
+ ->setName($monogram)
+ ->setFullName("{$monogram}: {$target_name}");
}
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildableQuery.php b/src/applications/harbormaster/query/HarbormasterBuildableQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildableQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildableQuery.php
@@ -10,8 +10,6 @@
private $manualBuildables;
private $needContainerObjects;
- private $needContainerHandles;
- private $needBuildableHandles;
private $needBuilds;
private $needTargets;
@@ -45,16 +43,6 @@
return $this;
}
- public function needContainerHandles($need) {
- $this->needContainerHandles = $need;
- return $this;
- }
-
- public function needBuildableHandles($need) {
- $this->needBuildableHandles = $need;
- return $this;
- }
-
public function needBuilds($need) {
$this->needBuilds = $need;
return $this;
@@ -99,60 +87,23 @@
}
protected function didFilterPage(array $page) {
- if ($this->needContainerObjects || $this->needContainerHandles) {
+ if ($this->needContainerObjects) {
$container_phids = array_filter(mpull($page, 'getContainerPHID'));
- if ($this->needContainerObjects) {
- $containers = array();
-
- if ($container_phids) {
- $containers = id(new PhabricatorObjectQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs($container_phids)
- ->setParentQuery($this)
- ->execute();
- $containers = mpull($containers, null, 'getPHID');
- }
-
- foreach ($page as $key => $buildable) {
- $container_phid = $buildable->getContainerPHID();
- $buildable->attachContainerObject(idx($containers, $container_phid));
- }
- }
-
- if ($this->needContainerHandles) {
- $handles = array();
-
- if ($container_phids) {
- $handles = id(new PhabricatorHandleQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs($container_phids)
- ->setParentQuery($this)
- ->execute();
- }
-
- foreach ($page as $key => $buildable) {
- $container_phid = $buildable->getContainerPHID();
- $buildable->attachContainerHandle(idx($handles, $container_phid));
- }
- }
- }
-
- if ($this->needBuildableHandles) {
- $handles = array();
-
- $handle_phids = array_filter(mpull($page, 'getBuildablePHID'));
- if ($handle_phids) {
- $handles = id(new PhabricatorHandleQuery())
+ if ($container_phids) {
+ $containers = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer())
- ->withPHIDs($handle_phids)
+ ->withPHIDs($container_phids)
->setParentQuery($this)
->execute();
+ $containers = mpull($containers, null, 'getPHID');
+ } else {
+ $containers = array();
}
foreach ($page as $key => $buildable) {
- $handle_phid = $buildable->getBuildablePHID();
- $buildable->attachBuildableHandle(idx($handles, $handle_phid));
+ $container_phid = $buildable->getContainerPHID();
+ $buildable->attachContainerObject(idx($containers, $container_phid));
}
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php
--- a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php
@@ -58,9 +58,7 @@
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new HarbormasterBuildableQuery())
- ->needContainerHandles(true)
- ->needBuildableHandles(true);
+ $query = id(new HarbormasterBuildableQuery());
$container_phids = $saved->getParameter('containerPHIDs', array());
if ($container_phids) {
@@ -185,23 +183,36 @@
$viewer = $this->requireViewer();
+ $phids = array();
+ foreach ($buildables as $buildable) {
+ $phids[] = $buildable->getContainerPHID();
+ $phids[] = $buildable->getBuildablePHID();
+ }
+ $handles = $viewer->loadHandles($phids);
+
+
$list = new PHUIObjectItemListView();
foreach ($buildables as $buildable) {
$id = $buildable->getID();
+ $container_phid = $buildable->getContainerPHID();
+ $buildable_phid = $buildable->getBuildablePHID();
+
$item = id(new PHUIObjectItemView())
->setHeader(pht('Buildable %d', $buildable->getID()));
- if ($buildable->getContainerHandle() !== null) {
- $item->addAttribute($buildable->getContainerHandle()->getName());
- }
- if ($buildable->getBuildableHandle() !== null) {
- $item->addAttribute($buildable->getBuildableHandle()->getFullName());
+
+ if ($container_phid) {
+ $handle = $handles[$container_phid];
+ $item->addAttribute($handle->getName());
}
- if ($id) {
- $item->setHref("/B{$id}");
+ if ($buildable_phid) {
+ $handle = $handles[$buildable_phid];
+ $item->addAttribute($handle->getFullName());
}
+ $item->setHref($buildable->getURI());
+
if ($buildable->getIsManualBuildable()) {
$item->addIcon('fa-wrench grey', pht('Manual'));
}
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php
--- a/src/applications/harbormaster/storage/HarbormasterBuildable.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php
@@ -13,8 +13,6 @@
private $buildableObject = self::ATTACHABLE;
private $containerObject = self::ATTACHABLE;
- private $buildableHandle = self::ATTACHABLE;
- private $containerHandle = self::ATTACHABLE;
private $builds = self::ATTACHABLE;
const STATUS_BUILDING = 'building';
@@ -70,6 +68,10 @@
return 'B'.$this->getID();
}
+ public function getURI() {
+ return '/'.$this->getMonogram();
+ }
+
/**
* Returns an existing buildable for the object's PHID or creates a
* new buildable implicitly if needed.
@@ -237,24 +239,6 @@
return $this->assertAttached($this->containerObject);
}
- public function attachContainerHandle($container_handle) {
- $this->containerHandle = $container_handle;
- return $this;
- }
-
- public function getContainerHandle() {
- return $this->assertAttached($this->containerHandle);
- }
-
- public function attachBuildableHandle($buildable_handle) {
- $this->buildableHandle = $buildable_handle;
- return $this;
- }
-
- public function getBuildableHandle() {
- return $this->assertAttached($this->buildableHandle);
- }
-
public function attachBuilds(array $builds) {
assert_instances_of($builds, 'HarbormasterBuild');
$this->builds = $builds;

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 8:48 AM (2 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387751
Default Alt Text
D15354.diff (9 KB)

Event Timeline