1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Tasks can be searched with task id in differential Task Selector

Summary:

Task selector didn't support searching tasks with their IDs, e.g., 'T17'.
This was confusing, because in the task list the task ID was visible, but you
could not search them.

Test Plan:

* Checked that searching 'T<task_id>' works with all the filters
* Checked that using multiple task IDs in the same query works
* Check that mixing task IDs and free text works

Reviewers: epriestley

CC: jungejason

Differential Revision: 105
This commit is contained in:
tuomaspelkonen 2011-04-05 22:32:37 -07:00
parent d5ee8c792c
commit d6d8598d68
2 changed files with 33 additions and 3 deletions

View file

@ -23,7 +23,18 @@ class ManiphestTaskSelectorSearchController extends ManiphestController {
$user = $request->getUser();
$query = new PhabricatorSearchQuery();
$query->setQuery($request->getStr('query'));
$query_str = $request->getStr('query');
$matches = array();
$task_ids = array();
// Collect all task IDs, e.g., T12 T651 T631, from the query string
preg_match_all('/\bT(\d+)\b/', $query_str, $matches);
if ($matches) {
$task_ids = $matches[1];
}
$query->setQuery($query_str);
$query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_TASK);
switch ($request->getStr('filter')) {
@ -42,9 +53,27 @@ class ManiphestTaskSelectorSearchController extends ManiphestController {
$exec = new PhabricatorSearchMySQLExecutor();
$results = $exec->executeSearch($query);
$results = ipull($results, 'phid');
$handles = id(new PhabricatorObjectHandleData($results))
$phids = array();
foreach ($results as $result) {
$phids[$result['phid']] = true;
}
// Do a separate query for task IDs if the query had them
if ($task_ids) {
$task_object = new ManiphestTask();
// It's OK to ignore filters, if user wants specific task IDs
$tasks = $task_object->loadAllWhere('id IN (%Ls)', $task_ids);
foreach ($tasks as $task) {
$phids[$task->getPHID()] = true;
}
}
$phids = array_keys($phids);
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$data = array();

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/phid/handle/view/selector');