mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Add a rough harbormaster.querybuildables
Conduit API method
Summary: Ref T4809. I need to sort out some of the "status" stuff we're doing before this is actually useful (there's no sensible "status" value to expose right now) but once that happens `arc` can query this to figure out whether it needs to warn the user about pending/failed builds. Test Plan: Ran query with various different parameters. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4809 Differential Revision: https://secure.phabricator.com/D8794
This commit is contained in:
parent
b5df5af04d
commit
3b0be0961c
4 changed files with 93 additions and 5 deletions
|
@ -190,6 +190,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_flag_edit_Method' => 'applications/flag/conduit/ConduitAPI_flag_edit_Method.php',
|
||||
'ConduitAPI_flag_query_Method' => 'applications/flag/conduit/ConduitAPI_flag_query_Method.php',
|
||||
'ConduitAPI_harbormaster_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_Method.php',
|
||||
'ConduitAPI_harbormaster_querybuildables_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuildables_Method.php',
|
||||
'ConduitAPI_harbormaster_sendmessage_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_sendmessage_Method.php',
|
||||
'ConduitAPI_macro_Method' => 'applications/macro/conduit/ConduitAPI_macro_Method.php',
|
||||
'ConduitAPI_macro_creatememe_Method' => 'applications/macro/conduit/ConduitAPI_macro_creatememe_Method.php',
|
||||
|
@ -2779,6 +2780,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_flag_edit_Method' => 'ConduitAPI_flag_Method',
|
||||
'ConduitAPI_flag_query_Method' => 'ConduitAPI_flag_Method',
|
||||
'ConduitAPI_harbormaster_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_harbormaster_querybuildables_Method' => 'ConduitAPI_harbormaster_Method',
|
||||
'ConduitAPI_harbormaster_sendmessage_Method' => 'ConduitAPI_harbormaster_Method',
|
||||
'ConduitAPI_macro_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_macro_creatememe_Method' => 'ConduitAPI_macro_Method',
|
||||
|
|
|
@ -216,7 +216,7 @@ abstract class ConduitAPIMethod
|
|||
$results['cursor'] = array(
|
||||
'limit' => $pager->getPageSize(),
|
||||
'after' => $pager->getNextPageID(),
|
||||
'before' =>$pager->getPrevPageID(),
|
||||
'before' => $pager->getPrevPageID(),
|
||||
);
|
||||
|
||||
return $results;
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
final class ConduitAPI_harbormaster_querybuildables_Method
|
||||
extends ConduitAPI_harbormaster_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return pht('Query Harbormaster buildables.');
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'ids' => 'optional list<id>',
|
||||
'phids' => 'optional list<phid>',
|
||||
'buildablePHIDs' => 'optional list<phid>',
|
||||
'containerPHIDs' => 'optional list<phid>',
|
||||
'manualBuildables' => 'optional bool',
|
||||
) + self::getPagerParamTypes();
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'wild';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$query = id(new HarbormasterBuildableQuery())
|
||||
->setViewer($viewer);
|
||||
|
||||
$ids = $request->getValue('ids');
|
||||
if ($ids !== null) {
|
||||
$query->withIDs($ids);
|
||||
}
|
||||
|
||||
$phids = $request->getValue('phids');
|
||||
if ($phids !== null) {
|
||||
$query->withPHIDs($phids);
|
||||
}
|
||||
|
||||
$buildable_phids = $request->getValue('buildablePHIDs');
|
||||
if ($buildable_phids !== null) {
|
||||
$query->withBuildablePHIDs($buildable_phids);
|
||||
}
|
||||
|
||||
$container_phids = $request->getValue('containerPHIDs');
|
||||
if ($container_phids !== null) {
|
||||
$query->withContainerPHIDs($container_phids);
|
||||
}
|
||||
|
||||
$manual = $request->getValue('manualBuildables');
|
||||
if ($manual !== null) {
|
||||
$query->withManualBuildables($manual);
|
||||
}
|
||||
|
||||
$pager = $this->newPager($request);
|
||||
|
||||
$buildables = $query->executeWithCursorPager($pager);
|
||||
|
||||
$data = array();
|
||||
foreach ($buildables as $buildable) {
|
||||
$monogram = $buildable->getMonogram();
|
||||
|
||||
$data[] = array(
|
||||
'id' => $buildable->getID(),
|
||||
'phid' => $buildable->getPHID(),
|
||||
'monogram' => $monogram,
|
||||
'uri' => PhabricatorEnv::getProductionURI('/'.$monogram),
|
||||
'buildablePHID' => $buildable->getBuildablePHID(),
|
||||
'containerPHID' => $buildable->getContainerPHID(),
|
||||
'isManualBuildable' => (bool)$buildable->getIsManualBuildable(),
|
||||
);
|
||||
}
|
||||
|
||||
$results = array(
|
||||
'data' => $data,
|
||||
);
|
||||
|
||||
$results = $this->addPagerResults($results, $pager);
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -175,28 +175,28 @@ final class HarbormasterBuildableQuery
|
|||
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
|
||||
if ($this->ids) {
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids) {
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->buildablePHIDs) {
|
||||
if ($this->buildablePHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'buildablePHID IN (%Ls)',
|
||||
$this->buildablePHIDs);
|
||||
}
|
||||
|
||||
if ($this->containerPHIDs) {
|
||||
if ($this->containerPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'containerPHID in (%Ls)',
|
||||
|
|
Loading…
Reference in a new issue