@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+93 -5
+2
src/__phutil_library_map__.php
··· 190 190 'ConduitAPI_flag_edit_Method' => 'applications/flag/conduit/ConduitAPI_flag_edit_Method.php', 191 191 'ConduitAPI_flag_query_Method' => 'applications/flag/conduit/ConduitAPI_flag_query_Method.php', 192 192 'ConduitAPI_harbormaster_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_Method.php', 193 + 'ConduitAPI_harbormaster_querybuildables_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuildables_Method.php', 193 194 'ConduitAPI_harbormaster_sendmessage_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_sendmessage_Method.php', 194 195 'ConduitAPI_macro_Method' => 'applications/macro/conduit/ConduitAPI_macro_Method.php', 195 196 'ConduitAPI_macro_creatememe_Method' => 'applications/macro/conduit/ConduitAPI_macro_creatememe_Method.php', ··· 2779 2780 'ConduitAPI_flag_edit_Method' => 'ConduitAPI_flag_Method', 2780 2781 'ConduitAPI_flag_query_Method' => 'ConduitAPI_flag_Method', 2781 2782 'ConduitAPI_harbormaster_Method' => 'ConduitAPIMethod', 2783 + 'ConduitAPI_harbormaster_querybuildables_Method' => 'ConduitAPI_harbormaster_Method', 2782 2784 'ConduitAPI_harbormaster_sendmessage_Method' => 'ConduitAPI_harbormaster_Method', 2783 2785 'ConduitAPI_macro_Method' => 'ConduitAPIMethod', 2784 2786 'ConduitAPI_macro_creatememe_Method' => 'ConduitAPI_macro_Method',
+1 -1
src/applications/conduit/method/ConduitAPIMethod.php
··· 216 216 $results['cursor'] = array( 217 217 'limit' => $pager->getPageSize(), 218 218 'after' => $pager->getNextPageID(), 219 - 'before' =>$pager->getPrevPageID(), 219 + 'before' => $pager->getPrevPageID(), 220 220 ); 221 221 222 222 return $results;
+86
src/applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuildables_Method.php
··· 1 + <?php 2 + 3 + final class ConduitAPI_harbormaster_querybuildables_Method 4 + extends ConduitAPI_harbormaster_Method { 5 + 6 + public function getMethodDescription() { 7 + return pht('Query Harbormaster buildables.'); 8 + } 9 + 10 + public function defineParamTypes() { 11 + return array( 12 + 'ids' => 'optional list<id>', 13 + 'phids' => 'optional list<phid>', 14 + 'buildablePHIDs' => 'optional list<phid>', 15 + 'containerPHIDs' => 'optional list<phid>', 16 + 'manualBuildables' => 'optional bool', 17 + ) + self::getPagerParamTypes(); 18 + } 19 + 20 + public function defineReturnType() { 21 + return 'wild'; 22 + } 23 + 24 + public function defineErrorTypes() { 25 + return array(); 26 + } 27 + 28 + protected function execute(ConduitAPIRequest $request) { 29 + $viewer = $request->getUser(); 30 + 31 + $query = id(new HarbormasterBuildableQuery()) 32 + ->setViewer($viewer); 33 + 34 + $ids = $request->getValue('ids'); 35 + if ($ids !== null) { 36 + $query->withIDs($ids); 37 + } 38 + 39 + $phids = $request->getValue('phids'); 40 + if ($phids !== null) { 41 + $query->withPHIDs($phids); 42 + } 43 + 44 + $buildable_phids = $request->getValue('buildablePHIDs'); 45 + if ($buildable_phids !== null) { 46 + $query->withBuildablePHIDs($buildable_phids); 47 + } 48 + 49 + $container_phids = $request->getValue('containerPHIDs'); 50 + if ($container_phids !== null) { 51 + $query->withContainerPHIDs($container_phids); 52 + } 53 + 54 + $manual = $request->getValue('manualBuildables'); 55 + if ($manual !== null) { 56 + $query->withManualBuildables($manual); 57 + } 58 + 59 + $pager = $this->newPager($request); 60 + 61 + $buildables = $query->executeWithCursorPager($pager); 62 + 63 + $data = array(); 64 + foreach ($buildables as $buildable) { 65 + $monogram = $buildable->getMonogram(); 66 + 67 + $data[] = array( 68 + 'id' => $buildable->getID(), 69 + 'phid' => $buildable->getPHID(), 70 + 'monogram' => $monogram, 71 + 'uri' => PhabricatorEnv::getProductionURI('/'.$monogram), 72 + 'buildablePHID' => $buildable->getBuildablePHID(), 73 + 'containerPHID' => $buildable->getContainerPHID(), 74 + 'isManualBuildable' => (bool)$buildable->getIsManualBuildable(), 75 + ); 76 + } 77 + 78 + $results = array( 79 + 'data' => $data, 80 + ); 81 + 82 + $results = $this->addPagerResults($results, $pager); 83 + return $results; 84 + } 85 + 86 + }
+4 -4
src/applications/harbormaster/query/HarbormasterBuildableQuery.php
··· 175 175 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 176 176 $where = array(); 177 177 178 - if ($this->ids) { 178 + if ($this->ids !== null) { 179 179 $where[] = qsprintf( 180 180 $conn_r, 181 181 'id IN (%Ld)', 182 182 $this->ids); 183 183 } 184 184 185 - if ($this->phids) { 185 + if ($this->phids !== null) { 186 186 $where[] = qsprintf( 187 187 $conn_r, 188 188 'phid IN (%Ls)', 189 189 $this->phids); 190 190 } 191 191 192 - if ($this->buildablePHIDs) { 192 + if ($this->buildablePHIDs !== null) { 193 193 $where[] = qsprintf( 194 194 $conn_r, 195 195 'buildablePHID IN (%Ls)', 196 196 $this->buildablePHIDs); 197 197 } 198 198 199 - if ($this->containerPHIDs) { 199 + if ($this->containerPHIDs !== null) { 200 200 $where[] = qsprintf( 201 201 $conn_r, 202 202 'containerPHID in (%Ls)',