mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Add "maniphest.find" to Conduit
Summary: Execute searches like the primary Maniphest task list. Let me know what else you guys need from this API. Test Plan: Executed "maniphest.info" and "maniphest.find" Reviewers: jungejason, tuomaspelkonen, aran, nh Reviewed By: nh CC: blair, skrul, aran, jungejason, epriestley, nh, tuomaspelkonen Differential Revision: 867
This commit is contained in:
parent
69445222f7
commit
76c11ea32e
5 changed files with 168 additions and 20 deletions
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_maniphest_find_Method
|
||||
extends ConduitAPI_maniphest_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Execute complex searches for Maniphest tasks.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
|
||||
$orders = array(
|
||||
ManiphestTaskQuery::ORDER_PRIORITY,
|
||||
ManiphestTaskQuery::ORDER_CREATED,
|
||||
ManiphestTaskQuery::ORDER_MODIFIED,
|
||||
);
|
||||
$orders = implode(', ', $orders);
|
||||
|
||||
$statuses = array(
|
||||
ManiphestTaskQuery::STATUS_ANY,
|
||||
ManiphestTaskQuery::STATUS_OPEN,
|
||||
ManiphestTaskQuery::STATUS_CLOSED,
|
||||
);
|
||||
$statuses = implode(', ', $statuses);
|
||||
|
||||
return array(
|
||||
'ownerPHIDs' => '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);
|
||||
}
|
||||
|
||||
}
|
13
src/applications/conduit/method/maniphest/find/__init__.php
Normal file
13
src/applications/conduit/method/maniphest/find/__init__.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/maniphest/base');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/query');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_maniphest_find_Method.php');
|
Loading…
Reference in a new issue