mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Allow "O42" to find packages by monogram in Owners typeaheads
Summary: When a user queries by package monogram explicitly, search by package ID. Test Plan: {F2305075} Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D17142
This commit is contained in:
parent
ef05bf335d
commit
10171e2101
1 changed files with 10 additions and 1 deletions
|
@ -22,9 +22,18 @@ final class PhabricatorOwnersPackageDatasource
|
|||
$results = array();
|
||||
|
||||
$query = id(new PhabricatorOwnersPackageQuery())
|
||||
->withNameNgrams($raw_query)
|
||||
->setOrder('name');
|
||||
|
||||
// If the user is querying by monogram explicitly, like "O123", do an ID
|
||||
// search. Otherwise, do an ngram substring search.
|
||||
if (preg_match('/^[oO]\d+\z/', $raw_query)) {
|
||||
$id = trim($raw_query, 'oO');
|
||||
$id = (int)$id;
|
||||
$query->withIDs(array($id));
|
||||
} else {
|
||||
$query->withNameNgrams($raw_query);
|
||||
}
|
||||
|
||||
$packages = $this->executeQuery($query);
|
||||
foreach ($packages as $package) {
|
||||
$name = $package->getName();
|
||||
|
|
Loading…
Reference in a new issue