Skip to content

Commit 377742c

Browse files
author
epriestley
committed
Get some level of meaningful status information into Harbormaster buildable list
Summary: Ref T1049. Nothing fancy, but shows red for fail/error and green for pass. See discussion in D7502. Test Plan: {F78839} Reviewers: hach-que, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1049 Differential Revision: https://secure.phabricator.com/D7512
1 parent c03cdbe commit 377742c

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

src/applications/harbormaster/controller/HarbormasterBuildableListController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ public function renderResultsList(
4444
}
4545

4646
$list->addItem($item);
47+
48+
// TODO: This is proof-of-concept for getting meaningful status
49+
// information into this list, and should get an improvement pass
50+
// once we're a little farther along.
51+
52+
$all_pass = true;
53+
$any_fail = false;
54+
foreach ($buildable->getBuilds() as $build) {
55+
if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) {
56+
$all_pass = false;
57+
}
58+
if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED ||
59+
$build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR) {
60+
$any_fail = true;
61+
}
62+
}
63+
64+
if ($any_fail) {
65+
$item->setBarColor('red');
66+
} else if ($all_pass) {
67+
$item->setBarColor('green');
68+
}
4769
}
4870

4971
return $list;

src/applications/harbormaster/query/HarbormasterBuildableQuery.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ final class HarbormasterBuildableQuery
1010

1111
private $needContainerObjects;
1212
private $needBuildableHandles;
13+
private $needBuilds;
1314

1415
public function withIDs(array $ids) {
1516
$this->ids = $ids;
@@ -41,6 +42,11 @@ public function needBuildableHandles($need) {
4142
return $this;
4243
}
4344

45+
public function needBuilds($need) {
46+
$this->needBuilds = $need;
47+
return $this;
48+
}
49+
4450
protected function loadPage() {
4551
$table = new HarbormasterBuildable();
4652
$conn_r = $table->establishConnection('r');
@@ -119,6 +125,18 @@ protected function didFilterPage(array $page) {
119125
}
120126
}
121127

128+
if ($this->needBuilds) {
129+
$builds = id(new HarbormasterBuildQuery())
130+
->setViewer($this->getViewer())
131+
->setParentQuery($this)
132+
->withBuildablePHIDs(mpull($page, 'getPHID'))
133+
->execute();
134+
$builds = mgroup($builds, 'getBuildablePHID');
135+
foreach ($page as $key => $buildable) {
136+
$buildable->attachBuilds(idx($builds, $buildable->getPHID(), array()));
137+
}
138+
}
139+
122140
return $page;
123141
}
124142

src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ public function buildSavedQueryFromRequest(AphrontRequest $request) {
1010
}
1111

1212
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
13-
$query = id(new HarbormasterBuildableQuery());
14-
$query->needBuildableHandles(true);
13+
$query = id(new HarbormasterBuildableQuery())
14+
->needBuildableHandles(true)
15+
->needBuilds(true);
1516

1617
return $query;
1718
}

src/applications/harbormaster/storage/HarbormasterBuildable.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ final class HarbormasterBuildable extends HarbormasterDAO
1111
private $buildableObject = self::ATTACHABLE;
1212
private $containerObject = self::ATTACHABLE;
1313
private $buildableHandle = self::ATTACHABLE;
14+
private $builds = self::ATTACHABLE;
1415

1516
const STATUS_WHATEVER = 'whatever';
1617

@@ -58,6 +59,16 @@ public function getBuildableHandle() {
5859
return $this->assertAttached($this->buildableHandle);
5960
}
6061

62+
public function attachBuilds(array $builds) {
63+
assert_instances_of($builds, 'HarbormasterBuild');
64+
$this->builds = $builds;
65+
return $this;
66+
}
67+
68+
public function getBuilds() {
69+
return $this->assertAttached($this->builds);
70+
}
71+
6172

6273
/* -( PhabricatorPolicyInterface )----------------------------------------- */
6374

0 commit comments

Comments
 (0)