1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Fix alternate filtering conditions in object selector dialog

Summary:
These didn't get updated either when the main search got rebuilt. Adjust and modernize them. Also this uses "exclude", which I couldn't find any callsites for but just missed, so restore that.

At some point I plan to swap this whole thing to ApplicationSearch and that will let us get rid of a bunch of stuff.

Test Plan: Searched for all filters, got sensible results, verified source object doesn't show up as a result.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, mbishopim3

Differential Revision: https://secure.phabricator.com/D8188
This commit is contained in:
epriestley 2014-02-11 07:45:33 -08:00
parent 094922bcb9
commit 4e70664ed4
2 changed files with 32 additions and 10 deletions

View file

@ -23,31 +23,36 @@ final class PhabricatorSearchSelectController
$query->setParameter('query', $query_str);
$query->setParameter('types', array($this->type));
$status_open = PhabricatorSearchRelationship::RELATIONSHIP_OPEN;
switch ($request->getStr('filter')) {
case 'assigned':
$query->setParameter('owner', array($user->getPHID()));
$query->setParameter('open', 1);
$query->setParameter('ownerPHIDs', array($user->getPHID()));
$query->setParameter('statuses', array($status_open));
break;
case 'created';
$query->setParameter('author', array($user->getPHID()));
$query->setParameter('authorPHIDs', array($user->getPHID()));
// TODO - if / when we allow pholio mocks to be archived, etc
// update this
if ($this->type != PholioPHIDTypeMock::TYPECONST) {
$query->setParameter('open', 1);
$query->setParameter('statuses', array($status_open));
}
break;
case 'open':
$query->setParameter('open', 1);
$query->setParameter('statuses', array($status_open));
break;
}
$query->setParameter('exclude', $request->getStr('exclude'));
$query->setParameter('limit', 100);
$query->setParameter('excludePHIDs', array($request->getStr('exclude')));
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
$results = $engine->executeSearch($query);
$results = id(new PhabricatorSearchDocumentQuery())
->setViewer($user)
->withSavedQuery($query)
->setOffset(0)
->setLimit(100)
->execute();
$phids = array_fill_keys($results, true);
$phids = array_fill_keys(mpull($results, 'getPHID'), true);
$phids += $this->queryObjectNames($query_str);
$phids = array_keys($phids);

View file

@ -25,6 +25,19 @@ final class PhabricatorSearchDocumentQuery
}
protected function willFilterPage(array $handles) {
// NOTE: This is used by the object selector dialog to exclude the object
// you're looking at, so that, e.g., a task can't be set as a dependency
// of itself in the UI.
// TODO: Remove this after object selection moves to ApplicationSearch.
$exclude = array();
if ($this->savedQuery) {
$exclude_phids = $this->savedQuery->getParameter('excludePHIDs', array());
$exclude = array_fuse($exclude_phids);
}
foreach ($handles as $key => $handle) {
if (!$handle->isComplete()) {
unset($handles[$key]);
@ -34,6 +47,10 @@ final class PhabricatorSearchDocumentQuery
unset($handles[$key]);
continue;
}
if (isset($exclude[$handle->getPHID()])) {
unset($handles[$key]);
continue;
}
}
return $handles;