diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php index ffe42c12c0..5a66de2129 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php @@ -44,6 +44,28 @@ final class HarbormasterBuildableListController } $list->addItem($item); + + // TODO: This is proof-of-concept for getting meaningful status + // information into this list, and should get an improvement pass + // once we're a little farther along. + + $all_pass = true; + $any_fail = false; + foreach ($buildable->getBuilds() as $build) { + if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) { + $all_pass = false; + } + if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED || + $build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR) { + $any_fail = true; + } + } + + if ($any_fail) { + $item->setBarColor('red'); + } else if ($all_pass) { + $item->setBarColor('green'); + } } return $list; diff --git a/src/applications/harbormaster/query/HarbormasterBuildableQuery.php b/src/applications/harbormaster/query/HarbormasterBuildableQuery.php index 6666e78955..decf9d8a40 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildableQuery.php +++ b/src/applications/harbormaster/query/HarbormasterBuildableQuery.php @@ -10,6 +10,7 @@ final class HarbormasterBuildableQuery private $needContainerObjects; private $needBuildableHandles; + private $needBuilds; public function withIDs(array $ids) { $this->ids = $ids; @@ -41,6 +42,11 @@ final class HarbormasterBuildableQuery return $this; } + public function needBuilds($need) { + $this->needBuilds = $need; + return $this; + } + protected function loadPage() { $table = new HarbormasterBuildable(); $conn_r = $table->establishConnection('r'); @@ -119,6 +125,18 @@ final class HarbormasterBuildableQuery } } + if ($this->needBuilds) { + $builds = id(new HarbormasterBuildQuery()) + ->setViewer($this->getViewer()) + ->setParentQuery($this) + ->withBuildablePHIDs(mpull($page, 'getPHID')) + ->execute(); + $builds = mgroup($builds, 'getBuildablePHID'); + foreach ($page as $key => $buildable) { + $buildable->attachBuilds(idx($builds, $buildable->getPHID(), array())); + } + } + return $page; } diff --git a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php index 81650aa081..c37aa7da3b 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php @@ -10,8 +10,9 @@ final class HarbormasterBuildableSearchEngine } public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { - $query = id(new HarbormasterBuildableQuery()); - $query->needBuildableHandles(true); + $query = id(new HarbormasterBuildableQuery()) + ->needBuildableHandles(true) + ->needBuilds(true); return $query; } diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php index d3a95edb44..ebaf15842f 100644 --- a/src/applications/harbormaster/storage/HarbormasterBuildable.php +++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php @@ -11,6 +11,7 @@ final class HarbormasterBuildable extends HarbormasterDAO private $buildableObject = self::ATTACHABLE; private $containerObject = self::ATTACHABLE; private $buildableHandle = self::ATTACHABLE; + private $builds = self::ATTACHABLE; const STATUS_WHATEVER = 'whatever'; @@ -58,6 +59,16 @@ final class HarbormasterBuildable extends HarbormasterDAO return $this->assertAttached($this->buildableHandle); } + public function attachBuilds(array $builds) { + assert_instances_of($builds, 'HarbormasterBuild'); + $this->builds = $builds; + return $this; + } + + public function getBuilds() { + return $this->assertAttached($this->builds); + } + /* -( PhabricatorPolicyInterface )----------------------------------------- */