From 4fc5f8e29751ca003e71f5bddf57701143a955ff Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 16 Apr 2015 08:18:55 -0700 Subject: [PATCH] Improve browsability of Diffusion repository datasource Summary: Ref T5750. Make browsing work and improve filtering. Test Plan: - Used browse UI. - Used normal search UI. {F373752} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5750 Differential Revision: https://secure.phabricator.com/D12434 --- .../DiffusionRepositoryDatasource.php | 9 ++++---- .../query/PhabricatorRepositoryQuery.php | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php index ca90766640..995a413d97 100644 --- a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php +++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php @@ -15,11 +15,12 @@ final class DiffusionRepositoryDatasource $viewer = $this->getViewer(); $raw_query = $this->getRawQuery(); - $results = array(); + $query = id(new PhabricatorRepositoryQuery()) + ->setOrder('name') + ->withDatasourceQuery($raw_query); + $repos = $this->executeQuery($query); - $repos = id(new PhabricatorRepositoryQuery()) - ->setViewer($viewer) - ->execute(); + $results = array(); foreach ($repos as $repo) { $results[] = id(new PhabricatorTypeaheadResult()) ->setName($repo->getMonogram().' '.$repo->getName()) diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php index 385ad37eaf..1b4e90fb22 100644 --- a/src/applications/repository/query/PhabricatorRepositoryQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -11,6 +11,7 @@ final class PhabricatorRepositoryQuery private $nameContains; private $remoteURIs; private $anyProjectPHIDs; + private $datasourceQuery; private $numericIdentifiers; private $callsignIdentifiers; @@ -103,6 +104,11 @@ final class PhabricatorRepositoryQuery return $this; } + public function withDatasourceQuery($query) { + $this->datasourceQuery = $query; + return $this; + } + public function needCommitCounts($need_counts) { $this->needCommitCounts = $need_counts; return $this; @@ -493,6 +499,21 @@ final class PhabricatorRepositoryQuery $this->anyProjectPHIDs); } + if (strlen($this->datasourceQuery)) { + // This handles having "rP" match callsigns starting with "P...". + $query = trim($this->datasourceQuery); + if (preg_match('/^r/', $query)) { + $callsign = substr($query, 1); + } else { + $callsign = $query; + } + $where[] = qsprintf( + $conn_r, + 'r.name LIKE %> OR r.callsign LIKE %>', + $query, + $callsign); + } + $where[] = $this->buildPagingClause($conn_r); return $this->formatWhereClause($where);