@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 specific close status queries to maniphest.find (and rename it to maniphest.query)

Summary:
- Allow clients to query for specific closed statuses (invalid, resolved, wontfix, etc), not just "closed" tasks.
- Rename this method to maniphest.query and deprecate maniphest.find as an alias to maniphest.query, for API consistency.

Test Plan: Ran queries for all tasks, "wontfix" tasks, closed tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2887

+160 -88
+3 -1
src/__phutil_library_map__.php
··· 170 170 'ConduitAPI_maniphest_find_Method' => 'applications/conduit/method/maniphest/ConduitAPI_maniphest_find_Method.php', 171 171 'ConduitAPI_maniphest_gettasktransactions_Method' => 'applications/conduit/method/maniphest/ConduitAPI_maniphest_gettasktransactions_Method.php', 172 172 'ConduitAPI_maniphest_info_Method' => 'applications/conduit/method/maniphest/ConduitAPI_maniphest_info_Method.php', 173 + 'ConduitAPI_maniphest_query_Method' => 'applications/conduit/method/maniphest/ConduitAPI_maniphest_query_Method.php', 173 174 'ConduitAPI_maniphest_update_Method' => 'applications/conduit/method/maniphest/ConduitAPI_maniphest_update_Method.php', 174 175 'ConduitAPI_owners_query_Method' => 'applications/conduit/method/owners/ConduitAPI_owners_query_Method.php', 175 176 'ConduitAPI_paste_Method' => 'applications/conduit/method/paste/ConduitAPI_paste_Method.php', ··· 1244 1245 'ConduitAPI_macro_query_Method' => 'ConduitAPI_macro_Method', 1245 1246 'ConduitAPI_maniphest_Method' => 'ConduitAPIMethod', 1246 1247 'ConduitAPI_maniphest_createtask_Method' => 'ConduitAPI_maniphest_Method', 1247 - 'ConduitAPI_maniphest_find_Method' => 'ConduitAPI_maniphest_Method', 1248 + 'ConduitAPI_maniphest_find_Method' => 'ConduitAPI_maniphest_query_Method', 1248 1249 'ConduitAPI_maniphest_gettasktransactions_Method' => 'ConduitAPI_maniphest_Method', 1249 1250 'ConduitAPI_maniphest_info_Method' => 'ConduitAPI_maniphest_Method', 1251 + 'ConduitAPI_maniphest_query_Method' => 'ConduitAPI_maniphest_Method', 1250 1252 'ConduitAPI_maniphest_update_Method' => 'ConduitAPI_maniphest_Method', 1251 1253 'ConduitAPI_owners_query_Method' => 'ConduitAPIMethod', 1252 1254 'ConduitAPI_paste_Method' => 'ConduitAPIMethod',
+10 -86
src/applications/conduit/method/maniphest/ConduitAPI_maniphest_find_Method.php
··· 1 1 <?php 2 2 3 3 /* 4 - * Copyright 2011 Facebook, Inc. 4 + * Copyright 2012 Facebook, Inc. 5 5 * 6 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 7 * you may not use this file except in compliance with the License. ··· 18 18 19 19 /** 20 20 * @group conduit 21 + * 22 + * @concrete-extensible 21 23 */ 22 24 final class ConduitAPI_maniphest_find_Method 23 - extends ConduitAPI_maniphest_Method { 24 - 25 - public function getMethodDescription() { 26 - return "Execute complex searches for Maniphest tasks."; 27 - } 28 - 29 - public function defineParamTypes() { 30 - 31 - $orders = array( 32 - ManiphestTaskQuery::ORDER_PRIORITY, 33 - ManiphestTaskQuery::ORDER_CREATED, 34 - ManiphestTaskQuery::ORDER_MODIFIED, 35 - ); 36 - $orders = implode(', ', $orders); 37 - 38 - $statuses = array( 39 - ManiphestTaskQuery::STATUS_ANY, 40 - ManiphestTaskQuery::STATUS_OPEN, 41 - ManiphestTaskQuery::STATUS_CLOSED, 42 - ); 43 - $statuses = implode(', ', $statuses); 44 - 45 - return array( 46 - 'ownerPHIDs' => 'optional list', 47 - 'authorPHIDs' => 'optional list', 48 - 'projectPHIDs' => 'optional list', 49 - 'ccPHIDs' => 'optional list', 50 - 51 - 'order' => 'optional enum<'.$orders.'>', 52 - 'status' => 'optional enum<'.$statuses.'>', 53 - 54 - 'limit' => 'optional int', 55 - 'offset' => 'optional int', 56 - ); 57 - } 25 + extends ConduitAPI_maniphest_query_Method { 58 26 59 - public function defineReturnType() { 60 - return 'list'; 27 + public function getMethodStatus() { 28 + return self::METHOD_STATUS_DEPRECATED; 61 29 } 62 30 63 - public function defineErrorTypes() { 64 - return array( 65 - ); 31 + public function getMethodStatusDescription() { 32 + return "Renamed to 'maniphest.query'."; 66 33 } 67 34 68 - protected function execute(ConduitAPIRequest $request) { 69 - $query = new ManiphestTaskQuery(); 70 - 71 - $owners = $request->getValue('ownerPHIDs'); 72 - if ($owners) { 73 - $query->withOwners($owners); 74 - } 75 - 76 - $authors = $request->getValue('authorPHIDs'); 77 - if ($authors) { 78 - $query->withAuthors($authors); 79 - } 80 - 81 - $projects = $request->getValue('projectPHIDs'); 82 - if ($projects) { 83 - $query->withProjects($projects); 84 - } 85 - 86 - $ccs = $request->getValue('ccPHIDs'); 87 - if ($ccs) { 88 - $query->withSubscribers($ccs); 89 - } 90 - 91 - $order = $request->getValue('order'); 92 - if ($order) { 93 - $query->setOrderBy($order); 94 - } 95 - 96 - $status = $request->getValue('status'); 97 - if ($status) { 98 - $query->withStatus($status); 99 - } 100 - 101 - $limit = $request->getValue('limit'); 102 - if ($limit) { 103 - $query->setLimit($limit); 104 - } 105 - 106 - $offset = $request->getValue('offset'); 107 - if ($offset) { 108 - $query->setOffset($offset); 109 - } 110 - 111 - $results = $query->execute(); 112 - return $this->buildTaskInfoDictionaries($results); 35 + public function getMethodDescription() { 36 + return "Deprecated alias of maniphest.query"; 113 37 } 114 38 115 39 }
+125
src/applications/conduit/method/maniphest/ConduitAPI_maniphest_query_Method.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + /** 20 + * @group conduit 21 + * 22 + * TODO: Remove maniphest.find, then make this final. 23 + * 24 + * @concrete-extensible 25 + */ 26 + class ConduitAPI_maniphest_query_Method 27 + extends ConduitAPI_maniphest_Method { 28 + 29 + 30 + public function getMethodDescription() { 31 + return "Execute complex searches for Maniphest tasks."; 32 + } 33 + 34 + public function defineParamTypes() { 35 + 36 + $orders = array( 37 + ManiphestTaskQuery::ORDER_PRIORITY, 38 + ManiphestTaskQuery::ORDER_CREATED, 39 + ManiphestTaskQuery::ORDER_MODIFIED, 40 + ); 41 + $orders = implode(', ', $orders); 42 + 43 + $statuses = array( 44 + ManiphestTaskQuery::STATUS_ANY, 45 + ManiphestTaskQuery::STATUS_OPEN, 46 + ManiphestTaskQuery::STATUS_CLOSED, 47 + ManiphestTaskQuery::STATUS_RESOLVED, 48 + ManiphestTaskQuery::STATUS_WONTFIX, 49 + ManiphestTaskQuery::STATUS_INVALID, 50 + ManiphestTaskQuery::STATUS_SPITE, 51 + ManiphestTaskQuery::STATUS_DUPLICATE, 52 + ); 53 + $statuses = implode(', ', $statuses); 54 + 55 + return array( 56 + 'ownerPHIDs' => 'optional list', 57 + 'authorPHIDs' => 'optional list', 58 + 'projectPHIDs' => 'optional list', 59 + 'ccPHIDs' => 'optional list', 60 + 61 + 'order' => 'optional enum<'.$orders.'>', 62 + 'status' => 'optional enum<'.$statuses.'>', 63 + 64 + 'limit' => 'optional int', 65 + 'offset' => 'optional int', 66 + ); 67 + } 68 + 69 + public function defineReturnType() { 70 + return 'list'; 71 + } 72 + 73 + public function defineErrorTypes() { 74 + return array( 75 + ); 76 + } 77 + 78 + protected function execute(ConduitAPIRequest $request) { 79 + $query = new ManiphestTaskQuery(); 80 + 81 + $owners = $request->getValue('ownerPHIDs'); 82 + if ($owners) { 83 + $query->withOwners($owners); 84 + } 85 + 86 + $authors = $request->getValue('authorPHIDs'); 87 + if ($authors) { 88 + $query->withAuthors($authors); 89 + } 90 + 91 + $projects = $request->getValue('projectPHIDs'); 92 + if ($projects) { 93 + $query->withProjects($projects); 94 + } 95 + 96 + $ccs = $request->getValue('ccPHIDs'); 97 + if ($ccs) { 98 + $query->withSubscribers($ccs); 99 + } 100 + 101 + $order = $request->getValue('order'); 102 + if ($order) { 103 + $query->setOrderBy($order); 104 + } 105 + 106 + $status = $request->getValue('status'); 107 + if ($status) { 108 + $query->withStatus($status); 109 + } 110 + 111 + $limit = $request->getValue('limit'); 112 + if ($limit) { 113 + $query->setLimit($limit); 114 + } 115 + 116 + $offset = $request->getValue('offset'); 117 + if ($offset) { 118 + $query->setOffset($offset); 119 + } 120 + 121 + $results = $query->execute(); 122 + return $this->buildTaskInfoDictionaries($results); 123 + } 124 + 125 + }
+22 -1
src/applications/maniphest/ManiphestTaskQuery.php
··· 40 40 const STATUS_ANY = 'status-any'; 41 41 const STATUS_OPEN = 'status-open'; 42 42 const STATUS_CLOSED = 'status-closed'; 43 + const STATUS_RESOLVED = 'status-resolved'; 44 + const STATUS_WONTFIX = 'status-wontfix'; 45 + const STATUS_INVALID = 'status-invalid'; 46 + const STATUS_SPITE = 'status-spite'; 47 + const STATUS_DUPLICATE = 'status-duplicate'; 43 48 44 49 private $priority = null; 45 50 ··· 282 287 } 283 288 284 289 private function buildStatusWhereClause($conn) { 290 + 291 + static $map = array( 292 + self::STATUS_RESOLVED => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 293 + self::STATUS_WONTFIX => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 294 + self::STATUS_INVALID => ManiphestTaskStatus::STATUS_CLOSED_INVALID, 295 + self::STATUS_SPITE => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 296 + self::STATUS_DUPLICATE => ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE, 297 + ); 298 + 285 299 switch ($this->status) { 286 300 case self::STATUS_ANY: 287 301 return null; ··· 290 304 case self::STATUS_CLOSED: 291 305 return 'status > 0'; 292 306 default: 293 - throw new Exception("Unknown status query '{$this->status}'!"); 307 + $constant = idx($map, $this->status); 308 + if (!$constant) { 309 + throw new Exception("Unknown status query '{$this->status}'!"); 310 + } 311 + return qsprintf( 312 + $conn, 313 + 'status = %d', 314 + $constant); 294 315 } 295 316 } 296 317