1
0
Fork 0
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:
epriestley 2017-01-04 14:40:09 -08:00
parent ef05bf335d
commit 10171e2101

View file

@ -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();