diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ed33b347be..90fd0d5a44 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -114,6 +114,7 @@ phutil_register_library_map(array( 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_maniphest_Method' => 'applications/conduit/method/maniphest/base', 'ConduitAPI_maniphest_createtask_Method' => 'applications/conduit/method/maniphest/createtask', + 'ConduitAPI_maniphest_find_Method' => 'applications/conduit/method/maniphest/find', 'ConduitAPI_maniphest_info_Method' => 'applications/conduit/method/maniphest/info', 'ConduitAPI_paste_Method' => 'applications/conduit/method/paste/base', 'ConduitAPI_paste_create_Method' => 'applications/conduit/method/paste/create', @@ -788,6 +789,7 @@ phutil_register_library_map(array( 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_maniphest_Method' => 'ConduitAPIMethod', 'ConduitAPI_maniphest_createtask_Method' => 'ConduitAPI_maniphest_Method', + 'ConduitAPI_maniphest_find_Method' => 'ConduitAPI_maniphest_Method', 'ConduitAPI_maniphest_info_Method' => 'ConduitAPI_maniphest_Method', 'ConduitAPI_paste_Method' => 'ConduitAPIMethod', 'ConduitAPI_paste_create_Method' => 'ConduitAPI_paste_Method', diff --git a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php index d825a3baa9..81779ea9e5 100644 --- a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php +++ b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php @@ -22,28 +22,45 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { protected function buildTaskInfoDictionary(ManiphestTask $task) { - $auxiliary = $task->loadAuxiliaryAttributes(); - $auxiliary = mpull($auxiliary, 'getValue', 'getName'); + $results = $this->buildTaskInfoDictionaries(array($task)); + return idx($results, $task->getPHID()); + } - $result = array( - 'id' => $task->getID(), - 'phid' => $task->getPHID(), - 'authorPHID' => $task->getAuthorPHID(), - 'ownerPHID' => $task->getOwnerPHID(), - 'ccPHIDs' => $task->getCCPHIDs(), - 'status' => $task->getStatus(), - 'priority' => ManiphestTaskPriority::getTaskPriorityName( - $task->getPriority()), - 'title' => $task->getTitle(), - 'description' => $task->getDescription(), - 'projectPHIDs' => $task->getProjectPHIDs(), - 'uri' => PhabricatorEnv::getProductionURI('/T'.$task->getID()), - 'auxiliary' => $auxiliary, + protected function buildTaskInfoDictionaries(array $tasks) { + if (!$tasks) { + return array(); + } - 'objectName' => 'T'.$task->getID(), - 'dateCreated' => $task->getDateCreated(), - 'dateModified' => $task->getDateModified(), - ); + $all_aux = id(new ManiphestTaskAuxiliaryStorage())->loadAllWhere( + 'taskPHID in (%Ls)', + mpull($tasks, 'getPHID')); + $all_aux = mgroup($all_aux, 'getTaskPHID'); + + $result = array(); + foreach ($tasks as $task) { + $auxiliary = idx($all_aux, $task->getPHID(), array()); + $auxiliary = mpull($auxiliary, 'getValue', 'getName'); + + $result[$task->getPHID()] = array( + 'id' => $task->getID(), + 'phid' => $task->getPHID(), + 'authorPHID' => $task->getAuthorPHID(), + 'ownerPHID' => $task->getOwnerPHID(), + 'ccPHIDs' => $task->getCCPHIDs(), + 'status' => $task->getStatus(), + 'priority' => ManiphestTaskPriority::getTaskPriorityName( + $task->getPriority()), + 'title' => $task->getTitle(), + 'description' => $task->getDescription(), + 'projectPHIDs' => $task->getProjectPHIDs(), + 'uri' => PhabricatorEnv::getProductionURI('/T'.$task->getID()), + 'auxiliary' => $auxiliary, + + 'objectName' => 'T'.$task->getID(), + 'dateCreated' => $task->getDateCreated(), + 'dateModified' => $task->getDateModified(), + ); + } return $result; } diff --git a/src/applications/conduit/method/maniphest/base/__init__.php b/src/applications/conduit/method/maniphest/base/__init__.php index ee28a563bd..f32f22aff8 100644 --- a/src/applications/conduit/method/maniphest/base/__init__.php +++ b/src/applications/conduit/method/maniphest/base/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'applications/conduit/method/base'); phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); +phutil_require_module('phabricator', 'applications/maniphest/storage/auxiliary'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/conduit/method/maniphest/find/ConduitAPI_maniphest_find_Method.php b/src/applications/conduit/method/maniphest/find/ConduitAPI_maniphest_find_Method.php new file mode 100644 index 0000000000..ba2c89a136 --- /dev/null +++ b/src/applications/conduit/method/maniphest/find/ConduitAPI_maniphest_find_Method.php @@ -0,0 +1,115 @@ + 'optional list', + 'authorPHIDs' => 'optional list', + 'projectPHIDs' => 'optional list', + 'ccPHIDs' => 'optional list', + + 'order' => 'optional enum<'.$orders.'>', + 'status' => 'optional enum<'.$statuses.'>', + + 'limit' => 'optional int', + 'offset' => 'optional int', + ); + } + + public function defineReturnType() { + return 'list'; + } + + public function defineErrorTypes() { + return array( + ); + } + + protected function execute(ConduitAPIRequest $request) { + $query = new ManiphestTaskQuery(); + + $owners = $request->getValue('ownerPHIDs'); + if ($owners) { + $query->withOwners($owners); + } + + $authors = $request->getValue('authorPHIDs'); + if ($authors) { + $query->withAuthors($authors); + } + + $projects = $request->getValue('projectPHIDs'); + if ($projects) { + $query->withProjects($projects); + } + + $ccs = $request->getValue('ccPHIDs'); + if ($ccs) { + $query->withSubscribers($ccs); + } + + $order = $request->getValue('order'); + if ($order) { + $query->setOrderBy($order); + } + + $status = $request->getValue('status'); + if ($status) { + $query->withStatus($status); + } + + $limit = $request->getValue('limit'); + if ($limit) { + $query->setLimit($limit); + } + + $offset = $request->getValue('offset'); + if ($offset) { + $query->setOffset($offset); + } + + $results = $query->execute(); + return $this->buildTaskInfoDictionaries($results); + } + +} diff --git a/src/applications/conduit/method/maniphest/find/__init__.php b/src/applications/conduit/method/maniphest/find/__init__.php new file mode 100644 index 0000000000..afd4b88be7 --- /dev/null +++ b/src/applications/conduit/method/maniphest/find/__init__.php @@ -0,0 +1,13 @@ +