mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
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
This commit is contained in:
parent
9437414f17
commit
4fc5f8e297
2 changed files with 26 additions and 4 deletions
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue