Page MenuHomePhabricator

D16356.diff
No OneTemporary

D16356.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1131,6 +1131,7 @@
'HarbormasterBuildPlanTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanTransactionQuery.php',
'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php',
'HarbormasterBuildRequest' => 'applications/harbormaster/engine/HarbormasterBuildRequest.php',
+ 'HarbormasterBuildSearchConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterBuildSearchConduitAPIMethod.php',
'HarbormasterBuildSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildSearchEngine.php',
'HarbormasterBuildStatus' => 'applications/harbormaster/constants/HarbormasterBuildStatus.php',
'HarbormasterBuildStatusDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildStatusDatasource.php',
@@ -1204,6 +1205,7 @@
'HarbormasterQueryAutotargetsConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryAutotargetsConduitAPIMethod.php',
'HarbormasterQueryBuildablesConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildablesConduitAPIMethod.php',
'HarbormasterQueryBuildsConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php',
+ 'HarbormasterQueryBuildsSearchEngineAttachment' => 'applications/harbormaster/engineextension/HarbormasterQueryBuildsSearchEngineAttachment.php',
'HarbormasterRemarkupRule' => 'applications/harbormaster/remarkup/HarbormasterRemarkupRule.php',
'HarbormasterRunBuildPlansHeraldAction' => 'applications/harbormaster/herald/HarbormasterRunBuildPlansHeraldAction.php',
'HarbormasterSchemaSpec' => 'applications/harbormaster/storage/HarbormasterSchemaSpec.php',
@@ -5637,6 +5639,7 @@
'HarbormasterDAO',
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
+ 'PhabricatorConduitResultInterface',
),
'HarbormasterBuildAbortedException' => 'Exception',
'HarbormasterBuildActionController' => 'HarbormasterController',
@@ -5691,6 +5694,7 @@
'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildRequest' => 'Phobject',
+ 'HarbormasterBuildSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'HarbormasterBuildSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterBuildStatus' => 'Phobject',
'HarbormasterBuildStatusDatasource' => 'PhabricatorTypeaheadDatasource',
@@ -5777,6 +5781,7 @@
'HarbormasterQueryAutotargetsConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterQueryBuildablesConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterQueryBuildsConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
+ 'HarbormasterQueryBuildsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'HarbormasterRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'HarbormasterRunBuildPlansHeraldAction' => 'HeraldAction',
'HarbormasterSchemaSpec' => 'PhabricatorConfigSchemaSpec',
diff --git a/src/applications/harbormaster/conduit/HarbormasterBuildSearchConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterBuildSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/conduit/HarbormasterBuildSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class HarbormasterBuildSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'harbormaster.build.search';
+ }
+
+ public function newSearchEngine() {
+ return new HarbormasterBuildSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Find out information about builds.');
+ }
+
+}
diff --git a/src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php
--- a/src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php
+++ b/src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php
@@ -11,6 +11,14 @@
return pht('Query Harbormaster builds.');
}
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return pht('Use %s instead.', 'harbormaster.build.search');
+ }
+
protected function defineParamTypes() {
return array(
'ids' => 'optional list<id>',
@@ -27,65 +35,39 @@
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
-
- $query = id(new HarbormasterBuildQuery())
- ->setViewer($viewer);
-
- $ids = $request->getValue('ids');
- if ($ids !== null) {
- $query->withIDs($ids);
- }
-
- $phids = $request->getValue('phids');
- if ($phids !== null) {
- $query->withPHIDs($phids);
- }
-
- $statuses = $request->getValue('buildStatuses');
- if ($statuses !== null) {
- $query->withBuildStatuses($statuses);
- }
-
- $buildable_phids = $request->getValue('buildablePHIDs');
- if ($buildable_phids !== null) {
- $query->withBuildablePHIDs($buildable_phids);
- }
-
- $build_plan_phids = $request->getValue('buildPlanPHIDs');
- if ($build_plan_phids !== null) {
- $query->withBuildPlanPHIDs($build_plan_phids);
- }
-
- $pager = $this->newPager($request);
-
- $builds = $query->executeWithCursorPager($pager);
-
- $data = array();
- foreach ($builds as $build) {
-
- $id = $build->getID();
- $uri = '/harbormaster/build/'.$id.'/';
- $status = $build->getBuildStatus();
- $status_name = HarbormasterBuildStatus::getBuildStatusName($status);
-
- $data[] = array(
- 'id' => $id,
- 'phid' => $build->getPHID(),
- 'uri' => PhabricatorEnv::getProductionURI($uri),
- 'name' => $build->getBuildPlan()->getName(),
- 'buildablePHID' => $build->getBuildablePHID(),
- 'buildPlanPHID' => $build->getBuildPlanPHID(),
- 'buildStatus' => $status,
- 'buildStatusName' => $status_name,
- );
+ $call = new ConduitCall(
+ 'harbormaster.build.search',
+ array_filter(array(
+ 'constraints' => array_filter(array(
+ 'ids' => $request->getValue('ids'),
+ 'phids' => $request->getValue('phids'),
+ 'statuses' => $request->getValue('buildStatuses'),
+ 'buildables' => $request->getValue('buildablePHIDs'),
+ 'plans' => $request->getValue('buildPlanPHIDs'),
+ )),
+ 'attachments' => array(
+ 'querybuilds' => true,
+ ),
+ 'limit' => $request->getValue('limit'),
+ 'before' => $request->getValue('before'),
+ 'after' => $request->getValue('after'),
+ )));
+
+ $subsumption = $call->setUser($viewer)
+ ->execute();
+
+ $data = [];
+ foreach ($subsumption['data'] as $build_data) {
+ $querybuilds = idxv($build_data, array('attachments', 'querybuilds'), []);
+ $fields = idx($build_data, 'fields', []);
+ unset($build_data['fields']);
+ unset($build_data['attachments']);
+ $data[] = array_mergev(array($build_data, $querybuilds, $fields));
}
- $results = array(
- 'data' => $data,
- );
+ $subsumption['data'] = $data;
- $results = $this->addPagerResults($results, $pager);
- return $results;
+ return $subsumption;
}
}
diff --git a/src/applications/harbormaster/engineextension/HarbormasterQueryBuildsSearchEngineAttachment.php b/src/applications/harbormaster/engineextension/HarbormasterQueryBuildsSearchEngineAttachment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/engineextension/HarbormasterQueryBuildsSearchEngineAttachment.php
@@ -0,0 +1,28 @@
+<?php
+
+final class HarbormasterQueryBuildsSearchEngineAttachment
+ extends PhabricatorSearchEngineAttachment {
+
+ public function getAttachmentName() {
+ return pht('Harbormaster Query Builds');
+ }
+
+ public function getAttachmentDescription() {
+ return pht(
+ 'This attachment exists solely to provide compatibility with the '.
+ 'message format returned by an outdated API method. It will be '.
+ 'taken away at some point and you should not rely on these fields '.
+ 'being available.');
+ }
+
+ public function getAttachmentForObject($object, $data, $spec) {
+ $status_name = HarbormasterBuildStatus::getBuildStatusName(
+ $object->getBuildStatus());
+ return array(
+ 'uri' => PhabricatorEnv::getProductionURI($object->getURI()),
+ 'name' => $object->getName(),
+ 'buildStatusName' => $status_name,
+ );
+ }
+
+}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
--- a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
@@ -24,6 +24,12 @@
->setDescription(
pht('Search for builds running a given build plan.'))
->setDatasource(new HarbormasterBuildPlanDatasource()),
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Buildables'))
+ ->setKey('buildables')
+ ->setAliases(array('buildable'))
+ ->setDescription(
+ pht('Search for builds running against particular buildables.')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Statuses'))
->setKey('statuses')
@@ -42,6 +48,12 @@
);
}
+ protected function getHiddenFields() {
+ return array(
+ 'buildables',
+ );
+ }
+
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -3,7 +3,8 @@
final class HarbormasterBuild extends HarbormasterDAO
implements
PhabricatorApplicationTransactionInterface,
- PhabricatorPolicyInterface {
+ PhabricatorPolicyInterface,
+ PhabricatorConduitResultInterface {
protected $buildablePHID;
protected $buildPlanPHID;
@@ -397,4 +398,49 @@
return pht('A build inherits policies from its buildable.');
}
+
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('buildablePHID')
+ ->setType('phid')
+ ->setDescription(pht('PHID of the object this build is building.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('buildPlanPHID')
+ ->setType('phid')
+ ->setDescription(pht('PHID of the build plan being run.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('buildStatus')
+ ->setType('map<string, wild>')
+ ->setDescription(pht('The current status of this build.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('initiatorPHID')
+ ->setType('phid')
+ ->setDescription(pht('The person (or thing) that started this build.')),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ $status = $this->getBuildStatus();
+ return array(
+ 'buildablePHID' => $this->getBuildablePHID(),
+ 'buildPlanPHID' => $this->getBuildPlanPHID(),
+ 'buildStatus' => array(
+ 'value' => $status,
+ 'name' => HarbormasterBuildStatus::getBuildStatusName($status),
+ ),
+ 'initiatorPHID' => nonempty($this->getInitiatorPHID(), null),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array(
+ id(new HarbormasterQueryBuildsSearchEngineAttachment())
+ ->setAttachmentKey('querybuilds'),
+ );
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 3:03 AM (17 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909866
Default Alt Text
D16356.diff (12 KB)

Event Timeline